rust/src/libstd
Alex Crichton 4d3cffa3cf std: Fix unsoundness of std:🧵:ScopedKey
Currently the compiler has no knowledge of `#[thread_local]` which forces users
to take on two burdens of unsafety:

* The lifetime of the borrow of a `#[thread_local]` static is **not** `'static`
* Types in `static`s are required to be `Sync`

The thread-local modules mostly curb these facets of unsafety by only allowing
very limited scopes of borrows as well as allowing all types to be stored in a
thread-local key (regardless of whether they are `Sync`) through an `unsafe
impl`.

Unfortunately these measures have the consequence of being able to take the
address of the key itself and send it to another thread, allowing the same key
to be accessed from two different threads. This is clearly unsafe, and this
commit fixes this problem with the same trick used by `LocalKey`, which is to
have an indirect function call to find the address of the *current thread's*
thread local. This way the address of thread local keys can safely be sent among
threads as their lifetime truly is `'static`.

This commit will reduce the performance of cross-crate scoped thread locals as
it now requires an indirect function call, but this can likely be overcome in a
future commit.

Closes #25894
2015-06-01 14:56:49 -07:00
..
collections Inline hash_table::calculate_offsets, used by iterators. 2015-05-31 11:03:46 +03:00
ffi Auto merge of #25416 - kballard:ffi-cstr-to-str-convenience, r=alexcrichton 2015-05-23 11:12:02 +00:00
io Mention UFCS sadness in instability messages 2015-05-28 10:34:40 -07:00
net Loosen timeout restrictions 2015-05-29 19:09:29 -07:00
num Remove mentions of int / uint from the isize / usize docs 2015-05-27 19:16:00 -04:00
os Rollup merge of #25140 - kevinmehall:mips, r=steveklabnik 2015-05-09 00:37:42 +05:30
prelude Rollup merge of #25224 - brson:stddoc, r=steveklabnik 2015-05-13 00:52:48 -04:00
rand remove references to IoResult 2015-05-28 12:51:01 -04:00
rt Use const fn to abstract away the contents of UnsafeCell & friends. 2015-05-27 11:19:03 +03:00
sync Use const fn to abstract away the contents of UnsafeCell & friends. 2015-05-27 11:19:03 +03:00
sys Auto merge of #25818 - sfackler:socket-timeouts, r=alexcrichton 2015-05-30 04:20:20 +00:00
thread std: Fix unsoundness of std:🧵:ScopedKey 2015-06-01 14:56:49 -07:00
time std: Redesign Duration, implementing RFC 1040 2015-05-13 17:50:58 -07:00
array.rs rustdoc: Support for "array" primitive 2015-03-23 14:02:34 -07:00
ascii.rs Model lexer: Fix remaining issues 2015-04-21 12:02:12 +02:00
bool.rs
dynamic_lib.rs Use const fn to abstract away the contents of UnsafeCell & friends. 2015-05-27 11:19:03 +03:00
env.rs Rollup merge of #25668 - steveklabnik:doc_const, r=alexcrichton 2015-05-28 00:35:20 +05:30
error.rs std: Don't use a wrapper for the float error type 2015-05-01 16:44:36 -07:00
fs.rs Rollup merge of #25128 - steveklabnik:gh24816, r=alexcrichton 2015-05-28 00:35:19 +05:30
lib.rs Use const fn to abstract away the contents of UnsafeCell & friends. 2015-05-27 11:19:03 +03:00
macros.rs Squeeze the last bits of tasks in documentation in favor of thread 2015-05-09 02:24:18 +09:00
panicking.rs std: Don't assume thread::current() works on panic 2015-04-27 16:15:36 -07:00
path.rs Auto merge of #25736 - tshepang:path-nits, r=steveklabnik 2015-05-25 01:56:48 +00:00
process.rs Auto merge of #25494 - alexcrichton:stdio-from-raw, r=aturon 2015-05-29 19:24:40 +00:00
rtdeps.rs std: Prepare for linking to musl 2015-04-27 10:11:15 -07:00
thunk.rs Remove Thunk struct and Invoke trait; change Thunk to be an alias 2015-04-01 14:41:21 -04:00
tuple.rs Remove doc-comment default::Default imports 2015-04-22 09:42:36 -04:00
unit.rs