Skip to content

c_str_alloc_error test: mention why this is mostly Miri-only - #163694

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
RalfJung:c_str_alloc_error
Oct 4, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
RalfJung:c_str_alloc_error

Conversation

@RalfJung

@RalfJung RalfJung commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

This was explained at the top of the file but I missed it there. Seems worth repeating at the attribute? Or am I just too blind?
Cc @bjorn3 -- is it expected that #[global_allocator] does not work in alloctests?

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

rustbot commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

r? @clarfonthey

rustbot has assigned @clarfonthey.
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 12 candidates
  • Random selection from Darksonn, JohnTitor, Mark-Simulacrum, clarfonthey

@bjorn3

bjorn3 commented Oct 3, 2026

Copy link
Copy Markdown
Member

It is expected #[global_allocator] doesn't work with -Cprefer-dynamic (and should probably be turned into an error). I didn't know alloctests was compiled with -Cprefer-dynamic though.

@RalfJung

RalfJung commented Oct 3, 2026

Copy link
Copy Markdown
Member Author

We have this

// When we build Rust dylibs they're all intended for intermediate
// usage, so make sure we pass the -Cprefer-dynamic flag instead of
// linking all deps statically into the dylib.
if matches!(mode, Mode::Std) {
rustflags.arg("-Cprefer-dynamic");
}

which I guess is also set for std tests.

@rust-log-analyzer

This comment has been minimized.

@clarfonthey

Copy link
Copy Markdown
Contributor

So, the test is mostly miri-only, but… I guess it is run outside miri?

Probably worth adding a comment to the top of the file too.

@RalfJung

RalfJung commented Oct 3, 2026 via email

Copy link
Copy Markdown
Member Author

@clarfonthey

Copy link
Copy Markdown
Contributor

Mostly just think that this comment might be worth mentioning near the top: that the main benefit of this test is for miri since the global allocator isn't applied under normal testing conditions.

@RalfJung

RalfJung commented Oct 3, 2026

Copy link
Copy Markdown
Member Author

That's what it says, isn't it?

//! This only
//! reproduces under Miri: in a normal build the `#[global_allocator]` below can't
//! intercept the reallocation inside `CString::clone_into` (it lives in libstd, which
//! library tests link with `-C prefer-dynamic`), so as a regular test it just checks
//! the happy path.

@RalfJung

RalfJung commented Oct 3, 2026

Copy link
Copy Markdown
Member Author

So I guess I was wrong when I said that this wasn't explained in the test. I just missed it. Up to you if you think also adding a comment at the attribute is worth it.

@clarfonthey

Copy link
Copy Markdown
Contributor

I guess I missed it too. I'll take over another look later and decide then.

@clarfonthey

Copy link
Copy Markdown
Contributor

Yeah, looking at it again, I think this is fine.

@bors r+ rollup

@rust-bors

rust-bors Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 4cc87c1 has been approved by clarfonthey

It is now in the queue for this repository.

@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 Oct 4, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 4, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #162974 (FCW for `#[panic_handler]` on `unsafe fn`.)
 - #163627 (Add documentation for the `no_main` and `repr` attributes)
 - #163671 (Add `--frontend-threads` option to `./x perf`)
 - #163694 (c_str_alloc_error test: mention why this is mostly Miri-only)
 - #163711 (Stabilize `CStr::display`)
 - #163723 ([tiny] Remove useless `.into()` calls)
@rust-bors
rust-bors Bot merged commit 5480218 into rust-lang:main Oct 4, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 4, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 4, 2026
Rollup merge of #163694 - RalfJung:c_str_alloc_error, r=clarfonthey

c_str_alloc_error test: mention why this is mostly Miri-only

This was explained at the top of the file but I missed it there. Seems worth repeating at the attribute? Or am I just too blind?
Cc @bjorn3 -- is it expected that `#[global_allocator]` does not work in alloctests?
@RalfJung
RalfJung deleted the c_str_alloc_error branch October 5, 2026 15:48
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.

5 participants