-
Notifications
You must be signed in to change notification settings - Fork 13k
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
std: Fix thread_local! in non-PIE binaries #24448
Conversation
r? @pcwalton (rust_highfive has picked a reviewer for you, use r? to override) |
r? @huonw |
@bors r+ |
📌 Commit 4d9cc4a has been approved by |
One of the parameters to the magical "register a thread-local destructor" function is called `__dso_handle` and largely just passed along (this seems to be what other implementations do). Currently we pass the *value* of this symbol, but apparently the correct piece of information to pass is the *address* of the symbol. In a PIE binary the symbol actually contains an address to itself which is why we've gotten away with what we're doing as long as we have. In a non-PIE binary the symbol contains the address `NULL`, causing a segfault in the runtime library if it keeps going. Closes rust-lang#24445
|
||
struct Destroy; | ||
impl Drop for Destroy { | ||
fn drop(&mut self) { println!("drop"); } |
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.
This test might not reproduce this issue in the future, when/if println!
does not depend on thread_local!
anymore.
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.
Oh this was actually just here to help me debug it, it's triggered via the use of X
instead of the contents of this destructor.
⌛ Testing commit 4d9cc4a with merge ae6f748... |
One of the parameters to the magical "register a thread-local destructor" function is called `__dso_handle` and largely just passed along (this seems to be what other implementations do). Currently we pass the *value* of this symbol, but apparently the correct piece of information to pass is the *address* of the symbol. In a PIE binary the symbol actually contains an address to itself which is why we've gotten away with what we're doing as long as we have. In a non-PIE binary the symbol contains the address `NULL`, causing a segfault in the runtime library if it keeps going. Closes rust-lang#24445
4d9cc4a
to
3e57c6c
Compare
One of the parameters to the magical "register a thread-local destructor" function is called `__dso_handle` and largely just passed along (this seems to be what other implementations do). Currently we pass the *value* of this symbol, but apparently the correct piece of information to pass is the *address* of the symbol. In a PIE binary the symbol actually contains an address to itself which is why we've gotten away with what we're doing as long as we have. In a non-PIE binary the symbol contains the address `NULL`, causing a segfault in the runtime library if it keeps going. Closes #24445
One of the parameters to the magical "register a thread-local destructor"
function is called
__dso_handle
and largely just passed along (this seems tobe what other implementations do). Currently we pass the value of this symbol,
but apparently the correct piece of information to pass is the address of the
symbol.
In a PIE binary the symbol actually contains an address to itself which is why
we've gotten away with what we're doing as long as we have. In a non-PIE binary
the symbol contains the address
NULL
, causing a segfault in the runtimelibrary if it keeps going.
Closes #24445