Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reintroduce logic for freeing memory on run-time errors #992

Merged
merged 5 commits into from
Feb 27, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/execution_plan/ops/op_project.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ static Record ProjectConsume(OpBase *opBase) {
}

Record projection = OpBase_CreateRecord(opBase);
// Track the inherited Record and the newly-allocated Record so that they may be freed if execution fails.
OpBase_AddVolatileRecord(opBase, r);
OpBase_AddVolatileRecord(opBase, projection);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if it would be better if we hold both r and projection within op_project as 2 additional fields,
As op_project is the only one using OpBase_AddVolatileRecord, OpBase_RemoveVolatileRecords
and we call these on each consume.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, OpBase_AddVolatileRecord and its free are also used in OpUpdate. This interface was introduced in #613, at which time it was used in all ops that call AR_EXP_Evaluate and have the potential to cause run-time errors.

That probably should still be the case, unless someone can come up with a better way of handling memory leaks on run-time errors.


for(uint i = 0; i < op->exp_count; i++) {
AR_ExpNode *exp = op->exps[i];
Expand All @@ -66,6 +69,7 @@ static Record ProjectConsume(OpBase *opBase) {
Record_Add(projection, rec_idx, v);
}

OpBase_RemoveVolatileRecords(opBase); // No exceptions encountered, Records are not dangling.
OpBase_DeleteRecord(r);
return projection;
}
Expand Down