-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[stdlib] relax stride check in UnsafePointer.withMemoryRebound #41553
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
Conversation
- The stride check in `UnsafePointer.withMemoryRebound` makes less sense when rebinding memory for a single element. - This skips the stride-matching portion of the `_debugPrecondition` in `withMemoryRebound` when `count == 1`.
@swift-ci please 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.
Thank you
@swift-ci please test |
@glessard, did you try building and testing NIO with this fix? I tried applying it to my Android CI with the Feb. 22 snapshot, but I still see it trap on Android x86_64. I just tried to reproduce on Fedora x86_64 by checking out the Feb. 22 snapshot and rebuilding the stdlib with this fix applied:
That will overwrite the broken stdlib with your fixed one, but it still traps:
lldb shows NIO failing here on linux x86_64, let me know if you can reproduce. |
@buttaface because these functions are _alwaysEmitIntoClient, rebuilding the standard library won't have any effect. You have to rebuild the dependent project and tests. |
I did, I just left those steps out in my last comment. After rebuilding the stdlib, I run Are you unable to reproduce? |
So far, I cannot reproduce. (my linux vm has not been available this weekend). I also don't understand how the assertion would trip since |
OK, I will investigate further and let you know. I didn't try running your stdlib test, will try it now. |
Looked into this more, this new test passes on linux, but maybe
The fact this doesn't break suggests to me your logical expression isn't being evaluated as you'd expect, ie it still checks the stride if the count is 1 and errors when that last condition is false. Maybe this test doesn't trigger that somehow, someone's going to have to check the codegen on linux. |
This is not the issue; the issue is that the ternary operator has lower precedence than |
@buttaface please give #41586 a spin |
Yep, that fixed it. |
Added a fix to the botched test in #41596 |
UnsafePointer.withMemoryRebound
makes less sense when rebinding memory for a single element._debugPrecondition
inwithMemoryRebound
whencount == 1
.Resolves SR-15912.