Skip to content

Commit

Permalink
Bug fix: allrules was deallocated too early
Browse files Browse the repository at this point in the history
  • Loading branch information
CerielJacobs committed Dec 13, 2019
1 parent c1d4d94 commit 565fcbf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/vlog/seminaiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class SemiNaiver {
size_t limitView,
bool fixpoint, unsigned long *timeout = NULL);

void prepare(size_t lastExecution, int singleRuleToCheck);
void prepare(size_t lastExecution, int singleRuleToCheck, std::vector<RuleExecutionDetails> &allrules);

void setIgnoreDuplicatesElimination() {
ignoreDuplicatesElimination = true;
Expand Down
8 changes: 5 additions & 3 deletions src/vlog/forward/seminaiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,13 @@ bool SemiNaiver::executeRules(std::vector<RuleExecutionDetails> &edbRuleset,
return newDer;
}

void SemiNaiver::prepare(size_t lastExecution, int singleRuleToCheck) {
void SemiNaiver::prepare(size_t lastExecution, int singleRuleToCheck, std::vector<RuleExecutionDetails> &allrules) {
//Prepare for the execution
#if DEBUG
std::chrono::system_clock::time_point start = std::chrono::system_clock::now();
LOG(DEBUGL) << "Optimizing ruleset...";
#endif
size_t allRulesSize = 0;
std::vector<RuleExecutionDetails> allrules;
for (auto& strata : allIDBRules) {
for (auto& ruleExecDetails: strata) {
#if DEBUG
Expand Down Expand Up @@ -316,7 +315,10 @@ void SemiNaiver::run(size_t lastExecution, size_t it, unsigned long *timeout,
#endif
listDerivations.clear();

prepare(lastExecution, singleRuleToCheck);
std::vector<RuleExecutionDetails> allrules;
// Note: allrules must be declared here, not in prepare itself, since when declared there,
// it (and stuff inside it) will be de-allocated too early. --Ceriel
prepare(lastExecution, singleRuleToCheck, allrules);

//Used for statistics
std::vector<StatIteration> costRules;
Expand Down

0 comments on commit 565fcbf

Please sign in to comment.