Skip to content

Conversation

@vtjnash
Copy link
Member

@vtjnash vtjnash commented Jun 14, 2019

fix #32215

unfortunately, while LLVM has a pass for exactly this purpose (RewriteStatepointsForGC::stripNonValidData),
C++ access rules prohibit us from using it and would require us to be named "coreclr"
to avoid an assertion error :/

See also https://reviews.llvm.org/D33756 for a more detailed explanation of the problem here.

@Keno
Copy link
Member

Keno commented Jun 14, 2019

Test case? If only at the LLVM level? Can you explain what causes the bug here? The linked LLVM revisions seems to talk about forwarding an unrelocated value across a statepoint, but since we don't do that, I assume it's not quite the same issue.

@vtjnash
Copy link
Member Author

vtjnash commented Jun 14, 2019

It's the same issue, although since our GC isn't quite as aggressive at modifying pointers at our state points, we don't need to be quite as conservative. For example, it seems likely that we can more easily keep llvm.invariant.end than with a moving collector.

Copy link
Member

@Keno Keno left a comment

Choose a reason for hiding this comment

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

LGTM, but I still think there needs to be a better explanation somewhere of why this is necessary. I wrote this code and it took me a few minutes to understand. Maybe something like:

Certain metadata (invariant.load, tbaa_const) allows reordering of memory operations over unknown calls (including safepoint). Before GC lowering this is legal, because the optimizer sinking a load over a safepoint will automatically extend the live range of the heap object (by definition the live range of the heap object before GC lowering matches the live ranges of any reference to it). However, after GC lowering, we have fixed the live ranges of the heap objects, and thus it is no longer legal to sink such memory operations over safepoints (as the update to the object's live range won't be tracked).

Certain metadata (invariant.load, tbaa_const) allows reordering of
memory operations over unknown calls (including safepoint). Before GC
lowering this is legal, because the optimizer sinking a load over a
safepoint will automatically extend the live range of the heap object
(by definition the live range of the heap object before GC lowering
matches the live ranges of any reference to it). However, after GC
lowering, we have fixed the live ranges of the heap objects, and thus it
is no longer legal to sink such memory operations over safepoints (as
the update to the object's live range won't be tracked).

fix #32215
@vtjnash
Copy link
Member Author

vtjnash commented Jun 25, 2019

OK, I've made that the commit message. I agree it's not something quite expected (as corroborated by the coreclr folks discovering a similar issue in their thinking too). I'm not even sure if this is entirely sufficient, or if we need to be even more aggressive at scrubbing attributes that lose their validity after the pass runs (like the patch above). But this at least fixed the reported issue.

@vtjnash vtjnash merged commit b2304c5 into master Jun 26, 2019
@vtjnash vtjnash deleted the jn/32215 branch June 26, 2019 16:23
@fredrikekre
Copy link
Member

Im guessing this should be backported since the closed issue is marked for backport?

@KristofferC KristofferC mentioned this pull request Jul 16, 2019
14 tasks
@JeffBezanson JeffBezanson modified the milestone: 1.2 Jul 30, 2019
JeffBezanson pushed a commit that referenced this pull request Jul 30, 2019
Certain metadata (invariant.load, tbaa_const) allows reordering of
memory operations over unknown calls (including safepoint). Before GC
lowering this is legal, because the optimizer sinking a load over a
safepoint will automatically extend the live range of the heap object
(by definition the live range of the heap object before GC lowering
matches the live ranges of any reference to it). However, after GC
lowering, we have fixed the live ranges of the heap objects, and thus it
is no longer legal to sink such memory operations over safepoints (as
the update to the object's live range won't be tracked).

fix #32215

(cherry picked from commit b2304c5)
@KristofferC KristofferC mentioned this pull request Aug 26, 2019
55 tasks
@KristofferC KristofferC mentioned this pull request Dec 3, 2019
56 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Program variable gets silently changed (memory corruption)

4 participants