protect evaluated lazy call in new_error_subscript_type() - #2174
Open
kevinushey wants to merge 1 commit into
Open
protect evaluated lazy call in new_error_subscript_type()#2174kevinushey wants to merge 1 commit into
kevinushey wants to merge 1 commit into
Conversation
The result of r_lazy_eval_protect() is a freshly allocated quote() wrapper whenever the lazy call evaluates to a language object. It was left unprotected while r_call_n() allocated the argument pairlist, so a GC during those allocations could collect it, corrupting the call field of the condition (or crashing R). KEEP() it like every other r_lazy_eval_protect() call site and bump the matching FREE(). Fixes r-lib#2173.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #2173.
new_error_subscript_type()was the onlyr_lazy_eval_protect()call site in the package that did notKEEP()its result. When the lazy call evaluates to a language object,r_lazy_eval_protect()returns a freshly allocatedquote()wrapper, which sat unprotected in theargsarray whiler_call_n()allocated the cons cells of the argument pairlist. A GC during those allocations collects the wrapper; the freed node is typically reused by the nextRf_cons(), so the condition'scallfield ends up as a cyclic pairlist pointing into the condition call's own arguments (and this can just as well crash R).This PR
KEEP()s the result (matching the call sites inconditions.c,match.c, andlist-combine.c) and bumps the matchingFREE(3)toFREE(4).Verified with the
gctorture()repro from #2173:conditionCall(cnd)becomes a self-referential dotted pair listconditionCall(cnd)isfoo(bar)as expectedtestthat::test_local(filter = "subscript")passes (262 tests).