Skip to content

alloctests: use thread-local in c_str_alloc_error - #165960

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Jules-Bertholet:unflake
Nov 17, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Jules-Bertholet:unflake

Conversation

@Jules-Bertholet

Copy link
Copy Markdown
Contributor

Fixes #165901

As suggested by @bjorn3 in #165901 (comment)

@rustbot

rustbot commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

Any special-casing of Miri in the standard library requires review.

cc @rust-lang/miri

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 14, 2026
@rustbot

rustbot commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

r? @ChrisDenton

rustbot has assigned @ChrisDenton.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 38 candidates
  • Random selection from ChrisDenton, JohnTitor, Mark-Simulacrum, clarfonthey, maxdexh

@rust-log-analyzer

This comment has been minimized.

@Jules-Bertholet
Jules-Bertholet force-pushed the unflake branch 2 times, most recently from 9c0972d to 887646e Compare November 14, 2026 15:17
@RalfJung

Copy link
Copy Markdown
Member

A better alternative may be to use a thread-local flag to control the allocator. Having the libtest harness around is nice e.g. for using nextest to run the tests.

@bjorn3

bjorn3 commented Nov 16, 2026

Copy link
Copy Markdown
Member

This test needs to be in a separate crate anyway and nextest is unlikely to work with the testing setup of the standard library. And finally it should be possible to add a check at the start of the test for --list --format terse that causes it to print c_str_alloc_error: test (or whatever test name) and then return as well as --list --format terse --ignored which would print nothing and exit as expected by nextest.

@RalfJung

RalfJung commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

nextest works very well in https://github.com/rust-lang/miri-test-libstd and I recently ported a no-harness test to use the harness because it was causing problems there. (#165993)

Thread-local storage "obviously" does the right thing and seems like the both easier and more correct fix here to me, compared to ad-hoc replicating parts of the libtest argument parsing.

@Jules-Bertholet

Copy link
Copy Markdown
Contributor Author

A better alternative may be to use a thread-local flag to control the allocator.

Yes, that makes a lot more sense. Done

@RalfJung

Copy link
Copy Markdown
Member

Thanks!
r? me
@bors r+

@rust-bors

rust-bors Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

📌 Commit a292cb1 has been tentatively approved by RalfJung

It will be put into the queue for this repository once PR CI succeeds.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 16, 2026
@Jules-Bertholet Jules-Bertholet changed the title alloctests: make c_str_alloc_error not use libtest alloctests: use thread-local in c_str_alloc_error Nov 16, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 16, 2026
alloctests: use thread-local in `c_str_alloc_error`

Fixes rust-lang#165901

As suggested by @bjorn3 in rust-lang#165901 (comment)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 16, 2026
alloctests: use thread-local in `c_str_alloc_error`

Fixes rust-lang#165901

As suggested by @bjorn3 in rust-lang#165901 (comment)
rust-bors Bot pushed a commit that referenced this pull request Nov 16, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - #166054 (stdarch subtree update)
 - #165289 (lexer: Update to Unicode 18)
 - #165960 (alloctests: use thread-local in `c_str_alloc_error`)
 - #166002 (#[optimize]: keep low opt levels unoptimized)
 - #166049 (rustc_target: Require altivec feature for ELFv2 powerpc64 targets)
 - #165200 (fix abi kind of thumb windows targets)
 - #165935 (Duplicate attribute diagnostic cleanups)
 - #165999 (Update TPDE submodule)
 - #166045 (rustdoc: Correctly filter deref impls on type aliases)
 - #166063 (Fix bad hyperlink)
 - #166066 (Update books)
 - #166072 (simplify Appearances iter)
 - #166075 (Remove dead code emitting `UnusedBuiltinAttribute`)
rust-bors Bot pushed a commit that referenced this pull request Nov 17, 2026
Rollup of 15 pull requests

Successful merges:

 - #166054 (stdarch subtree update)
 - #165939 (Convert `pretty-std` debuginfo test to `gdb-repr`)
 - #165289 (lexer: Update to Unicode 18)
 - #165960 (alloctests: use thread-local in `c_str_alloc_error`)
 - #166002 (#[optimize]: keep low opt levels unoptimized)
 - #166003 (Fix ICE in tail_expr_drop_order lint with async drops)
 - #166049 (rustc_target: Require altivec feature for ELFv2 powerpc64 targets)
 - #165200 (fix abi kind of thumb windows targets)
 - #165966 (Document failing cases for spawning processes when using Command)
 - #165999 (Update TPDE submodule)
 - #166045 (rustdoc: Correctly filter deref impls on type aliases)
 - #166063 (Fix bad hyperlink)
 - #166066 (Update books)
 - #166072 (simplify Appearances iter)
 - #166075 (Remove dead code emitting `UnusedBuiltinAttribute`)
@rust-bors
rust-bors Bot merged commit 2b1c934 into rust-lang:main Nov 17, 2026
14 checks passed
@rustbot rustbot added this to the 1.102.0 milestone Nov 17, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 17, 2026
Rollup merge of #165960 - Jules-Bertholet:unflake, r=RalfJung

alloctests: use thread-local in `c_str_alloc_error`

Fixes #165901

As suggested by @bjorn3 in #165901 (comment)
@Jules-Bertholet
Jules-Bertholet deleted the unflake branch November 17, 2026 11:38
github-actions Bot pushed a commit to rust-lang/stdarch that referenced this pull request Nov 19, 2026
Rollup of 15 pull requests

Successful merges:

 - rust-lang/rust#166054 (stdarch subtree update)
 - rust-lang/rust#165939 (Convert `pretty-std` debuginfo test to `gdb-repr`)
 - rust-lang/rust#165289 (lexer: Update to Unicode 18)
 - rust-lang/rust#165960 (alloctests: use thread-local in `c_str_alloc_error`)
 - rust-lang/rust#166002 (#[optimize]: keep low opt levels unoptimized)
 - rust-lang/rust#166003 (Fix ICE in tail_expr_drop_order lint with async drops)
 - rust-lang/rust#166049 (rustc_target: Require altivec feature for ELFv2 powerpc64 targets)
 - rust-lang/rust#165200 (fix abi kind of thumb windows targets)
 - rust-lang/rust#165966 (Document failing cases for spawning processes when using Command)
 - rust-lang/rust#165999 (Update TPDE submodule)
 - rust-lang/rust#166045 (rustdoc: Correctly filter deref impls on type aliases)
 - rust-lang/rust#166063 (Fix bad hyperlink)
 - rust-lang/rust#166066 (Update books)
 - rust-lang/rust#166072 (simplify Appearances iter)
 - rust-lang/rust#166075 (Remove dead code emitting `UnusedBuiltinAttribute`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

alloctests::c_str_alloc_error is flaky: global ARMED flag lets libtest's main thread take the injected allocation failure

6 participants