Uh oh!
There was an error while loading. Please reload this page.
Ensure TLS accesses don't call the global allocator through panic (part 2) - #160976
Conversation
maxdexh
commented
Aug 12, 2026
There are still some code paths that can panic... |
38e1492 to
46ec7c3Comparemaxdexh
commented
Aug 12, 2026
It wasn't that bad, most of the panicking code in the modules (which are way too spread apart) was in the destructor code, which can panic anyway and isn't called on access |
nia-e
commented
Aug 12, 2026
grepping for // unwrap
os.rs106:let layout = Layout::new::<Value<T>>().align_to(ALIGN).unwrap();142:let layout = Layout::new::<Value<T>>().align_to(ALIGN).unwrap();
key/xous.rs191:.unwrap()
key/windows.rs191:let dtor = unsafe{(*cur).dtor.unwrap()};// assert
guard/key.rs53: debug_assert_eq!(state,RUN);
key/xous.rs111: assert!((*val).is_null());are these not also possible violations of our guarantee? ^^ |
maxdexh
commented
Aug 12, 2026
As long as they can't happen, no. But I'll take a look at them |
Note that there are also uses of indexing and addition, but to me they didn't look like they can go wrong. Maybe we should replace them anyway? |
maxdexh
commented
Aug 12, 2026
Thinking about it, we probably should. They are essentially unchecked operations without safety comments. I'll get back to it... |
@nia-e is there a way to test the build against all targets? I would like to slap all the panic-related |
nia-e
commented
Aug 12, 2026
i think the only way unless you have a lot of cross-compilation set up locally is to do a bors try job with a bunch of architectures ^^ you should(?) have perms for that |
maxdexh
commented
Aug 12, 2026
Uh I'll try (haha get it) |
46ec7c3 to
4385391CompareI think this is it? Edit: Welp |
@maxdexh: 🔑 Insufficient privileges: not in try users |
This comment has been minimized.
This comment has been minimized.
4385391 to
09946ecComparemaxdexh
commented
Aug 12, 2026
Okay at least some targets are in the CI ^^ |
464d969 to
9b1df30Comparemaxdexh
commented
Aug 12, 2026
test-various was just a random job i picked up from a rollup PR, idk what that job even does |
maxdexh
commented
Aug 12, 2026
Yeah test-various doesn't test any exotic platforms from what i can see in the job details |
This comment has been minimized.
This comment has been minimized.
f77d1cb to
5b71324CompareFor some reason |
nia-e
commented
Aug 12, 2026
this looks a lot better ^^ even if it's not everything, it's def meaningfully reducing the potential unwind surface. ty! @bors r+ rollup=iffy |
Rollup of 13 pull requests Successful merges: - #160976 (Ensure TLS accesses don't call the global allocator through panic (part 2)) - #160438 ([rustdoc] Change table odd table rows background color to not make it the same as inline code) - #160985 (self-profile more of borrowck) - #137858 (Add new `unused_footnote_definition` rustdoc lint) - #159566 (Add support for generics in `offload`and remove `no_mangle` attribute) - #160676 (rustc_public: split `def`s out of `ty`) - #160861 (rustc_parse: suggest removing semicolon before `if` block) - #160958 (Remove unused `#[non_exhaustive]` in library) - #160978 (move resolve_path to Session inherent method) - #160990 (Remove old cfg parser which is now dead code) - #160991 (Add offload component on nightly) - #160999 (doc changes to expect messages in process.rs) - #161003 (Also warn if an invalid `doc` attribute is used on a macro invocation)
maxdexh
commented
Aug 13, 2026
Yeah I don't feel comfortable closing the issue until we have a way to auto detect such code |
Rollup of 13 pull requests Successful merges: - #160976 (Ensure TLS accesses don't call the global allocator through panic (part 2)) - #160438 ([rustdoc] Change table odd table rows background color to not make it the same as inline code) - #160985 (self-profile more of borrowck) - #137858 (Add new `unused_footnote_definition` rustdoc lint) - #159566 (Add support for generics in `offload`and remove `no_mangle` attribute) - #160676 (rustc_public: split `def`s out of `ty`) - #160861 (rustc_parse: suggest removing semicolon before `if` block) - #160958 (Remove unused `#[non_exhaustive]` in library) - #160978 (move resolve_path to Session inherent method) - #160990 (Remove old cfg parser which is now dead code) - #160991 (Add offload component on nightly) - #160999 (doc changes to expect messages in process.rs) - #161003 (Also warn if an invalid `doc` attribute is used on a macro invocation)
Uh oh!
There was an error while loading. Please reload this page.
Rollup merge of #160976 - maxdexh:fix-thread-local-global-alloc-reenter-2, r=nia-e Ensure TLS accesses don't call the global allocator through panic (part 2) In #160934, I missed some calls that are reachable from `LocalKey::with` on platforms that use the racy `LazyKey` implementation. How it didn't occur to me that the other functions (besides `get` and `set`) are reachable is beyond me ^^ I guess this is what I get for going through call graphs of disabled code by hand. Yet another argument for function coloring. r? nia-e
rust-timer
commented
Aug 18, 2026
Finished benchmarking commit (004192f): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -1.6%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -2.0%, secondary -3.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.2%, secondary -7.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 455.642s -> 457.256s (0.35%) |
Kobzol
commented
Aug 18, 2026
This caused a small regression, but also a large win on one stress test. Overall, it is mostly neutral. @rustbot label: +perf-regression-triaged |
…loc-reenter-3, r=nia-e Ensure TLS accesses don't call the global allocator through panic (part 3) Follow-up to rust-lang#160976 Missed TLS code that is in a completely different module for some reason cc rust-lang#160930
…loc-reenter-3, r=nia-e Ensure TLS accesses don't call the global allocator through panic (part 3) Follow-up to rust-lang#160976 Missed TLS code that is in a completely different module for some reason cc rust-lang#160930
…loc-reenter-3, r=nia-e Ensure TLS accesses don't call the global allocator through panic (part 3) Follow-up to rust-lang#160976 Missed TLS code that is in a completely different module for some reason cc rust-lang#160930
…loc-reenter-3, r=nia-e Ensure TLS accesses don't call the global allocator through panic (part 3) Follow-up to rust-lang#160976 Missed TLS code that is in a completely different module for some reason cc rust-lang#160930
…er-3, r=nia-e Ensure TLS accesses don't call the global allocator through panic (part 3) Follow-up to rust-lang/rust#160976 Missed TLS code that is in a completely different module for some reason cc rust-lang/rust#160930
View all comments
In #160934, I missed some calls that are reachable from
LocalKey::withon platforms that use the racyLazyKeyimplementation.How it didn't occur to me that the other functions (besides
getandset) are reachable is beyond me ^^I guess this is what I get for going through call graphs of disabled code by hand.
Yet another argument for function coloring.
r? nia-e