Skip to content

Commit

Permalink
[cilksan] Fix resizing of frame stack to move frame data from old sta…
Browse files Browse the repository at this point in the history
…ck to new, in order to resolve double-free memory issues.
  • Loading branch information
neboat committed Nov 4, 2023
1 parent f4fd00c commit d3b6236
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions cilksan/frame_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,30 @@ struct FrameData_t {
return Iterbag;
}

FrameData_t &operator=(FrameData_t &&that) {
Sbag_used = that.Sbag_used;
Iterbag_used = that.Iterbag_used;
frame_data = that.frame_data;
InContin = that.InContin;
ParentContin = that.ParentContin;
num_Pbags = that.num_Pbags;
Sbag = that.Sbag;
Pbags = that.Pbags;
Iterbag = that.Iterbag;
reducer_views = that.reducer_views;

that.Sbag_used = false;
that.Iterbag_used = false;
that.InContin = 0;
that.ParentContin = 0;
that.num_Pbags = 0;
that.Sbag = nullptr;
that.Pbags = nullptr;
that.Iterbag = nullptr;
that.reducer_views = nullptr;

return *this;
}
};

#endif // __FRAME_DATA_H__
2 changes: 1 addition & 1 deletion cilksan/stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Stack_t {

// Copy contents of old call stack
for (uint32_t i = 0; i < copy_end; ++i) {
_stack[i] = old_stack[i];
_stack[i] = std::move(old_stack[i]);
}
_capacity = new_capacity;

Expand Down

0 comments on commit d3b6236

Please sign in to comment.