-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[sil] Expand immutable address use verification to in_guaranteed parameters. #24610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[sil] Expand immutable address use verification to in_guaranteed parameters. #24610
Conversation
@swift-ci smoke test |
lib/SIL/SILVerifier.cpp
Outdated
|
||
bool isConsumingOrMutatingYieldUse(Operand *use) { | ||
// For now, just say that it is non-consuming for now. | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops missed this one. I am going to need to fix this.
Hmmm... I thought I was able to get rid the entire compiler. I wonder what changed. The failure here looks like a real use after free. |
Unless I am reading the result incorrectly, both are hitting something related to:
|
(%1 above is an in_guaranteed parameter) |
Looks fine so far. I wonder if we should verify that |
9bef127
to
5937648
Compare
@swift-ci smoke test |
The failure on macOS isn't reproducing for me. |
@swift-ci smoke test |
Found the problem (turns out someone updated this code earlier today and I hadn't rebased to get the info). FSO is converting @in -> @in_guaranteed in a funky way. So this is most likely /not/ a real use-after-free. I need to understand it better. |
@atrick this one is a good one. The bug was real. So this check has caught 2 bugs so far ; ). SILCombine is miscompiling the following code:
by transforming it into:
|
@gottesmm there's a value substitution that ignores the ownership of the apply argument. I'm not sure how your new verification caught that since it's got nothing to do with immutability. Let me know if you want me to debug that bad SILCombine. I think the problem is that |
@atrick The way this was caught by my check is FSO changed this to in_guaranteed in a specific case. |
…ction thunks. The machinery assumes that it will always have a +1 value. I am attempting to do the minimal fix here for cherry-picking purposes. There isn't a test case with this commit since the immutable address verifier (in the next commit) verifies that this is done correctly. The specific test that will trip is vtable_thunks_reabstraction.swift. rdar://50212579
5937648
to
2a0cbfb
Compare
@swift-ci smoke test |
@atrick I updated the PR with the fix for sil-combine. |
@swift-ci smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There's a failure in lldb/ExclusivityREPL test. Could verification be exposing a bug there too? |
@swift-ci smoke test os x platform |
@atrick I ran the tests locally and I am seeing: Testing Time: 295.52s Failing Tests (1): Maybe the lldb tests are flaky now? Not sure. |
…meters when we have a copy of the underlying value. Otherwise, we may get use-after-frees as in the added test. rdar://50609145
2a0cbfb
to
afe3114
Compare
@swift-ci smoke test |
1 similar comment
@swift-ci smoke test |
The main commit in this PR expands our immutable address verification from only being used with open_existential_addr to also being used with in_guaranteed parameters. Beyond catching actual invalid uses of in_guaranteed parameters, this also ensures that we do not hit the assert after inlining a callee (with a mutable use of an in_guaranteed parameter) into a caller that has an immutable open_existential_addr (triggering the original assertion).
The 2nd commit fixes a small issue exposed by the test vtable_thunks_reabstraction.swift that causes the verifier to trip.
rdar://50212579