From 3e57c6c3ba0d7bfb6ad85915052406be1f218dbc Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 14 Apr 2015 23:26:42 -0700 Subject: std: Fix thread_local! in non-PIE binaries 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 --- src/libstd/thread/local.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libstd') diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index cc4031cc180..6d8f1cba709 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -373,7 +373,7 @@ mod imp { arg: *mut u8, dso_handle: *mut u8) -> libc::c_int; mem::transmute::<*const (), F>(__cxa_thread_atexit_impl) - (dtor, t, __dso_handle); + (dtor, t, &__dso_handle as *const _ as *mut _); return } -- cgit 1.4.1-3-g733a5