-
Notifications
You must be signed in to change notification settings - Fork 0
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
"Local Exec" TLS model is used sometimes, resulting in different TLS addresses calculated and thus segfaults #457
Comments
…tack to `ia2_stackptr_0` and thus uses the correct GOT thread local Without this, sometimes the assignment to `ia2_stackptr_0` in `INIT_RUNTIME` in the main compartment ended up using a "Local Exec" thread local that had a different address, and thus segfaulted. This is a workaround to #457, but doesn't actually fix the root issue. It does successfully prevent compartmentalized `dav1d` from segfaulting, though.
… TLS model issue and prevent segfaulting `allocate_stack_0` writes the allocated stack to `ia2_stackptr_0`. Previously, this was done inline in `init_stacks_and_setup_tls`, which is defined in the main compartment with `INIT_RUNTIME`, and thus may sometimes use the "Local Exec" TLS model and thus use a different thread-local address. Moving this to `allocate_stack_0` in `libia2` forces it to use the correct GOT thread local. This is a workaround to #457, but doesn't actually fix the root issue. It does successfully prevent compartmentalized `dav1d` from segfaulting, though.
Do you have any way to get this crashing build again? Can I reproduce it? I'm having a hard time getting this to reproduce in a smaller test case. I'm only getting the compiler to generate the following sequence, instead of the hardcoded TLS offset we saw.
If I recall correctly we were seeing basically |
It still reproduces the same for me when I have ia2 on the latest
This is the faulting instruction for me:
0x555555558ed7 <init_stacks_and_setup_tls+600>: mov %rax,%fs:0xffffffffffffe000
4ed7: 64 48 89 04 25 00 e0 ff ff movq %rax, %fs:-0x2000 The |
… TLS model issue and prevent segfaulting `allocate_stack_0` writes the allocated stack to `ia2_stackptr_0`. Previously, this was done inline in `init_stacks_and_setup_tls`, which is defined in the main compartment with `INIT_RUNTIME`, and thus may sometimes use the "Local Exec" TLS model and thus use a different thread-local address. Moving this to `allocate_stack_0` in `libia2` forces it to use the correct GOT thread local. This is a workaround to #457, but doesn't actually fix the root issue. It does successfully prevent compartmentalized `dav1d` from segfaulting, though.
After compartmentalizing
dav1d
and trying to run it, I started hitting a segfault at the very beginning, ininit_stacks_and_setup_tls
:IA2-Phase2/runtime/libia2/include/ia2_internal.h
Line 433 in 94f890b
This segfault wasn't initially happening, but like #455 and #456, started happening suddenly.
After much debugging with @rinon, we determined that the main compartment's DSO, which calls
INIT_RUNTIME
and thus definesinit_stacks_and_setup_tls
, was calculating a different address for the thread-localia2_stackptr_0
as compared to other DSOs likeliblibia2.a
.As @ahomescu explained to @rinon,
We were able to workaround this by moving the assignment in
IA2-Phase2/runtime/libia2/include/ia2_internal.h
Line 433 in 94f890b
allocate_stack_0
, defined inlibia2
, thus preventing it from trying to use this "Local Exec" TLS model. While a valid workaround, this is just a workaround, as the root issue is still there, and I wonder if it may also be causing issues like #455 and #456.The text was updated successfully, but these errors were encountered: