<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/tests/ui/runtime/stdout-before-main.rs, branch try-perf</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=try-perf</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=try-perf'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2024-10-12T11:01:36+00:00</updated>
<entry>
<title>std: fix stdout-before-main</title>
<updated>2024-10-12T11:01:36+00:00</updated>
<author>
<name>joboet</name>
<email>jonasboettiger@icloud.com</email>
</author>
<published>2024-10-12T11:01:36+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=9f91c5099fb7261cf8c85cc638d2692a317060ec'/>
<id>urn:sha1:9f91c5099fb7261cf8c85cc638d2692a317060ec</id>
<content type='text'>
Fixes #130210.

Since #124881, `ReentrantLock` uses `ThreadId` to identify threads. This has the unfortunate consequence of breaking uses of `Stdout` before main: Locking the `ReentrantLock` that synchronizes the output will initialize the thread ID before the handle for the main thread is set in `rt::init`. But since that would overwrite the current thread ID, `thread::set_current` triggers an abort.

This PR fixes the problem by using the already initialized thread ID for constructing the main thread handle and allowing `set_current` calls that do not change the thread's ID.
</content>
</entry>
</feed>
