-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Disallow _Atomic(uint64_t)
in structs, since some C compilers have an alignment bug
#56626
Comments
For example, here is a CI failure we saw on a PR (#56320) that introduced new
|
Can we not do the other way? Disallow C compilers that don't support this? |
That would make sense to me. |
iiuc that would mean disallowing GCC entirely. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65146 is still open |
I believe the status is just wrong and this got fixed in the commit linked at the bottom of that issue. |
In the meantime, why not just manually force the padding and set the alignment? |
@Keno: that would be excellent if it would work in all cases. Do you mean something like this?:
or even this?:
Don't we need to worry about CC: @d-netto (PS I'm trying this in a commit, here) |
If that works, that'd be great. From @vtjnash explanation it sounded like it wouldn't, in which case I would have suggested aligning the outer struct. That said, from the commit that fixed it, I don't see anything to suggest that the attribute would be ignored (of course it's possible the surrounding code would do something like that). |
Huh, it does seem to have fixed the segfault in CI, anyway! 👀 Is that enough to consider this fixed, then? |
(This also seems to be what Stackoverflow says) |
🤔 but the tests are failing on i686 (32-bit), which makes me think that actually forcing the alignment just causes us to read/write garbage even though it doesn't crash? 😞 Or maybe the issue is that now the struct layouts don't match between julia and C? |
Per @vtjnash:
This can result in segfaults and other issues (on 32-bit machines only?).
Currently, we have atomic uint64s in these two structs:
We should change these to 32-bit uints if we can, or find some other encoding if not.
Additionally, we should make a static analyzer rule that disallows this for the future.
A clang-tidy plugin could check this for us.
The text was updated successfully, but these errors were encountered: