Skip to content
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

Merged
merged 1 commit into from
Apr 16, 2015

Conversation

alexcrichton
Copy link
Member

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

@rust-highfive
Copy link
Collaborator

r? @pcwalton

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton
Copy link
Member Author

r? @huonw

@rust-highfive rust-highfive assigned huonw and unassigned pcwalton Apr 15, 2015
@huonw
Copy link
Member

huonw commented Apr 15, 2015

@bors r+

@bors
Copy link
Contributor

bors commented Apr 15, 2015

📌 Commit 4d9cc4a has been approved by huonw

Manishearth added a commit to Manishearth/rust that referenced this pull request Apr 15, 2015
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
bors added a commit that referenced this pull request Apr 15, 2015
@Manishearth
Copy link
Member


struct Destroy;
impl Drop for Destroy {
fn drop(&mut self) { println!("drop"); }
Copy link
Member

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.

Copy link
Member Author

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.

@bors
Copy link
Contributor

bors commented Apr 15, 2015

⌛ 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
@alexcrichton
Copy link
Member Author

@bors: r=huonw 3e57c6c

@bors
Copy link
Contributor

bors commented Apr 16, 2015

⌛ Testing commit 3e57c6c with merge 5576b05...

bors added a commit that referenced this pull request Apr 16, 2015
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
@bors bors merged commit 3e57c6c into rust-lang:master Apr 16, 2015
@alexcrichton alexcrichton deleted the issue-24445 branch April 30, 2015 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

thread_local!s with destructors segfault in non-PIE executables
7 participants