summaryrefslogtreecommitdiff
path: root/src/ModuleCache.cc
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2012-09-08 20:48:15 (GMT)
committerMarius Kintel <marius@kintel.net>2012-09-08 20:48:15 (GMT)
commit3b6f16605c2dcdabca39dd0d61653cc8c72fa72d (patch)
tree255c5192b381edb371333a5ea9eaddd79e9f2cc9 /src/ModuleCache.cc
parent66601933ab899b4d823a3c3b94cb0614e0e99d68 (diff)
Fix bug where recently compiled module happened to receive the same pointer value as the module it replaced, causing dependency tracking not to work properly. Related to #75
Diffstat (limited to 'src/ModuleCache.cc')
-rw-r--r--src/ModuleCache.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/ModuleCache.cc b/src/ModuleCache.cc
index d03d121..c215342 100644
--- a/src/ModuleCache.cc
+++ b/src/ModuleCache.cc
@@ -75,17 +75,22 @@ Module *ModuleCache::evaluate(const std::string &filename)
std::string text((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
print_messages_push();
-
+
+ Module *oldmodule = NULL;
cache_entry e = { NULL, cache_id };
if (this->entries.find(filename) != this->entries.end()) {
- delete this->entries[filename].module;
+ oldmodule = this->entries[filename].module;
}
this->entries[filename] = e;
std::string pathname = boosty::stringy(fs::path(filename).parent_path());
lib_mod = dynamic_cast<Module*>(parse(text.c_str(), pathname.c_str(), false));
+ PRINTB_NOCACHE(" compiled module: %p", lib_mod);
if (lib_mod) {
+ // We defer deletion so we can ensure that the new module won't
+ // have the same address as the old
+ delete oldmodule;
this->entries[filename].module = lib_mod;
} else {
this->entries.erase(filename);
contact: Jan Huwald // Impressum