This is an archive of the discontinued LLVM Phabricator instance.

[AAPointerInfo] fix assertion at the pass-through use of a pointer
ClosedPublic

Authored by sameerds on Jan 1 2023, 10:18 PM.

Details

Summary

HandlePassthroughUser may sometimes create a new entry for the OffsetInfo of a
user in the OffsetInfoMap. This can invalidate outstanding references into the
map, including the one which needs to be copied into the new entry. This
produces invalid offset info that can trigger assertions.

Fixed this by not using references at this point. The bug was originally
introduced in commit ID 0dc0a441323d41b4860668f38d290579e0de130c.

Diff Detail

Event Timeline

sameerds created this revision.Jan 1 2023, 10:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 1 2023, 10:18 PM
sameerds requested review of this revision.Jan 1 2023, 10:18 PM
Herald added a reviewer: sstefan1. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
arsenm added a subscriber: arsenm.Jan 2 2023, 5:43 AM

Testcase?

Testcase?

I am not sure how to go about writing a reliable test for an invalidated reference into a container, especially a map. It would have to depend on possibly adding enough entries to cause a reallocation, or inserting keys in an order that causes earlier keys to be moved around. What would such a test actually check? That the invalidation "never" happens?

arsenm added a comment.EditedJan 2 2023, 8:08 AM

Testcase?

I am not sure how to go about writing a reliable test for an invalidated reference into a container, especially a map. It would have to depend on possibly adding enough entries to cause a reallocation, or inserting keys in an order that causes earlier keys to be moved around. What would such a test actually check? That the invalidation "never" happens?

What does llvm-reduce give you if you just feed your original testcase to it?

sameerds updated this revision to Diff 485870.Jan 2 2023, 9:00 AM

Actually fix the root cause. The previous change was cleaned up too hastily and completely missed the point of the fix.

ronlieb accepted this revision.Jan 2 2023, 10:05 AM
ronlieb added a subscriber: ronlieb.

lgtm, passed the 5 internal tests that failed.

This revision is now accepted and ready to land.Jan 2 2023, 10:05 AM
This revision was landed with ongoing or failed builds.Jan 4 2023, 3:24 AM
This revision was automatically updated to reflect the committed changes.

Testcase?

I am not sure how to go about writing a reliable test for an invalidated reference into a container, especially a map. It would have to depend on possibly adding enough entries to cause a reallocation, or inserting keys in an order that causes earlier keys to be moved around. What would such a test actually check? That the invalidation "never" happens?

What does llvm-reduce give you if you just feed your original testcase to it?

It did produce a pretty small testcase, but it was not convincing. The crash only happens with "opt -O3", at the point where a specific pass OpenMPOptCGSCC runs. All optimizations up to that point have no effect on the test IR, but running only that pass does not produce a crash. It's basically a very fragile situation where all the earlier passes produce an application state that just happens to produce the right invalidation inside the map. That's not very robust.