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
threadlocal generates a segfault on Apple Silicon #7527
Labels
Milestone
Comments
kubkon
added
os-macos
upstream
An issue with a third party project that Zig uses.
arch-aarch64
64-bit ARM
labels
Dec 22, 2020
kubkon
added a commit
to kubkon/zig
that referenced
this issue
Dec 22, 2020
Test barred on issue ziglang#7527.
kubkon
added a commit
to kubkon/zig
that referenced
this issue
Dec 23, 2020
Tests barred on issue ziglang#7527.
kubkon
added a commit
to kubkon/zig
that referenced
this issue
Jan 20, 2021
This commit brings back stack trace printing on ARM Darwin OSes by avoiding the use of `threadlocal` for keeping track of panic stages per thread. Essentially, LLVM/LLD fails to properly emit thread-local variables which causes a segfault on attempting access. Since the default panic handler relies on a threadlocal to keep track of panic stages per thread using a thread-local variable, we ensure at compilation time that ARM Darwin platforms explicitly opt-out from this in favour of storing the panic stages per thread in a hash-map behind a mutex. This is a temporary solution until the underlying issue is fixed but much welcome one since this brings back stack traces printouts on ARM macOS without the necessity to resort to the system linker and still get broken stack traces due to addressing differences between the system linker and LLD. For a more complete overview of the problem with `threadlocal` in LLVM, see ziglang#7527.
kubkon
added a commit
to kubkon/zig
that referenced
this issue
Jan 21, 2021
This temporary patch fixes a segfault caused by miscompilation by the LLD when generating stubs for initialization of thread local storage. We effectively bypass TLS in the default panic handler so that no segfault is generated and the stack trace is correctly reported back to the user. Note that, this is linked directly to a bigger issue with LLD ziglang#7527 and when resolved, we only need to remove the `comptime` code path introduced with this patch to use the default panic handler that relies on TLS. Co-authored-by: Andrew Kelley <andrew@ziglang.org>
kubkon
added a commit
that referenced
this issue
Jan 21, 2021
This temporary patch fixes a segfault caused by miscompilation by the LLD when generating stubs for initialization of thread local storage. We effectively bypass TLS in the default panic handler so that no segfault is generated and the stack trace is correctly reported back to the user. Note that, this is linked directly to a bigger issue with LLD #7527 and when resolved, we only need to remove the `comptime` code path introduced with this patch to use the default panic handler that relies on TLS. Co-authored-by: Andrew Kelley <andrew@ziglang.org>
dgbuckley
pushed a commit
to dgbuckley/zig
that referenced
this issue
Mar 9, 2021
This temporary patch fixes a segfault caused by miscompilation by the LLD when generating stubs for initialization of thread local storage. We effectively bypass TLS in the default panic handler so that no segfault is generated and the stack trace is correctly reported back to the user. Note that, this is linked directly to a bigger issue with LLD ziglang#7527 and when resolved, we only need to remove the `comptime` code path introduced with this patch to use the default panic handler that relies on TLS. Co-authored-by: Andrew Kelley <andrew@ziglang.org>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
The following snippet:
compiles and cross-compiles fine on
aarch64-macos-gnu
; however, generates aSEGFAULT
when run due to a deficiency in LLVM's LLD linker. The same snippet works fine when linked using Apple's system linkerld
or onx86_64
using LLD.The text was updated successfully, but these errors were encountered: