-
Notifications
You must be signed in to change notification settings - Fork 114
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
Threading primitives are not aligned properly #194
Comments
This is probably PPC specific (as x86-64 works). I have no idea what could trigger a bus error, the argument appears correct. |
A bit of googling says that it is probably bad alignment on the lock (SIGBUS can come from misaligned accesses). |
Forcing Since this is part of Considering that this is inside (Alignments appear correct, and I would expect the problem to exist with |
libstd uses |
But when is that assignment made? |
|
Observing that const TargetArch ARCH_POWERPC64LE = {
"powerpc64",
64, false,
{ /*atomic(u8)=*/true, true, true, true, true },
TargetArch::Alignments(2, 4, 8, 16, 4, 8, 8)
}; So why isn't it being aligned? FWIW, the actual results of merely adding |
X86 doesn't care about alignment as much as other architectures, so it wouldn't be too surprising to me if this alignment issue exists on all platforms. |
Seems like |
Check the |
Not sure how I got the original backtrace - having trouble getting one with the arguments not optimised out at this point (since Currently looking at
The very first mutex-related call has the misaligned address:
|
make -f minicargo.mk LIBS
fails: Bus error
Testing locally shows that they are aligned properly (well, an assert shows that they're correct). |
printf("%d\n", (int)alignof(pthread_mutex_t)); tells me 8 I would expect if this were a system problem, the issue would affect a lot more than just mrustc...? |
I meant the mrustc-emitted type (within libstd.rlib.c). From my local checks, it's correctly aligned to 8 bytes (EDIT: Was checking 1.29, not 1.39 - 1.39 is wrong) |
I don't know what I am looking for then |
The above commit included an assertion that the alignment is correct (at least, the C matches the value expected by mrustc). Locally (x86-64 linux), this has an alignment of 1, ... which seems wrong - might be a failure in handling |
// struct ::"libc-0_2_62_Hd"::unix::linux_like::linux::pthread_mutex_t
struct s_ZRG4ch4libc90_2_62_Hd4unix10linux_like5linux15pthread_mutex_t0g {
t_ZRTA40Ca _0; // [u8; 40]
} ; |
Confirmed - |
… pointer if alignment more than 1 pointer) (ref #194)
Potential fix in the above commit, waiting for it to regression test on linux |
Seems good @luke-jr Mind checking with your PPC64 branch? |
… pointer if alignment more than 1 pointer) (ref thepowersgang#194)
@luke-jr Reminder: Can you confirm that the above fix works for you? |
@luke-jr Still looking for confirmation. Alignment should be properly supported now, but I'd like to confirm before closing the issue. |
Neither ffb0961 (w/ patches) nor current master work for me, apparently due to issues unrelated to alignment (but it has been far too long to confirm the alignment-related issue is fixed or not). |
16d1d29 was the commit that originally addressed this issue. |
specifically in output-1.39.0/libcore.rlib.c |
aed9b36 is the first bad commit (for the |
Trying 6f42b74,
Looking at the mentioned assert line, it sounds like it may still be an alignment-related issue :/ |
Can you identify which structure is badly aligned? |
The panic happens at https://github.com/rust-lang/hashbrown/blob/e7cd4a57a2690f199a527434f635206363ad661f/src/raw/mod.rs#L1086 which asserts that a "control bytes" pointer is aligned to the "group width". If on x86 this may be |
the |
@luke-jr Can you confirm that the issue still exists? I have a very fuzzy memory of seeing a similar error when a constant expression wasn't properly converted to a |
As of f08a7cb trying to build 1.39.0:
I don't know how I would diagnose it further? |
A backtrace from that panic would help, and maybe a some reading of the generated code to see if you can see where that |
Also: what platform are you on? I can't seem to reproduce this failure on mint 20.3 ( |
I'm running into this issue as well (powerpc64le using guix to build rust). Is anyone still working on this or is a workaround known? How can I help? |
@mrvdb |
The text was updated successfully, but these errors were encountered: