SourceExprCommand: allocate the vSourceExpr via uncollectable memory #3492
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously the memory would occasionally be collected during eval since
the GC doesn't consider the member variable as alive / doesn't scan the
region of memory where the pointer lives.
By using the traceable_allocator allocator provided by Boehm GC we
can ensure the memory isn't collected. It should be properly freed when
SourceExprCommand goes out of scope.
Related to #3475
I've been running my reproducer for >20min. Usually it would trigger the error within a few minutes. So far it looks very stable. Having spent some time on reading through the code and the various GC docs I believe this might be the correct fix (or approach).
The
vSourceExpr
will be released when the current command (CmdBulid
) goes out of scope. That is probably fine as that is basically the same as the lifetime of the entire program.I would appreciate if we could get this into a stable (v2.3-branch) release.