c-variadic: initialize the copied VaList in const-eval#157977
Conversation
|
Some changes occurred to the CTFE machinery
cc @rust-lang/miri Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri |
|
|
| fn clone() { | ||
| pub unsafe extern "C" fn clone_the_va_list(args: ...) { | ||
| // The implicit `drop` will catch a `VaList` that isn't properly initialized. | ||
| let _ = args.clone(); | ||
| } | ||
|
|
||
| unsafe { clone_the_va_list(1i32, 2i32) } | ||
| } | ||
|
|
There was a problem hiding this comment.
Could you also add tests to make sure that interleaving next_arg() with clone() in various combinations work correctly (give correct return values in miri)?
There was a problem hiding this comment.
Sure, I added some.
6af9b67 to
eb8f617
Compare
This comment has been minimized.
This comment has been minimized.
|
Hmm, we hit an interesting case here where we do have a fallback body, but that fallback is not valid for How should I work around this? |
eb8f617 to
867b361
Compare
Skip those tests under |
There was a problem hiding this comment.
Thanks! I just have some nits and clarification questions.
@rustbot author
| fn clone_and_advance() { | ||
| if cfg!(force_intrinsic_fallback) { | ||
| // Skip this test when we use the fallback bodies, the fallback body does | ||
| // not hook into the Miri bookkeeping that we need to detect UB. |
There was a problem hiding this comment.
This test does not have UB though? I don't understand this comment.
There was a problem hiding this comment.
With the flag enabled Miri thinks there is UB though
https://triage.rust-lang.org/gha-logs/rust-lang/rust/81717608108
We then duplicate a VaList by just duplicating the bits (a memcpy) and that is fine for LLVM but for Miri we don't set up the allocations correctly in that case.
There was a problem hiding this comment.
Yes, I understand that you do need to skip the test when fallback bodies are on. But the comment currently doesn't make sense.
There was a problem hiding this comment.
It's also kind of bad that "force-intrinsic-fallbacks" reports incorrect UB. That's not supposed to happen.
There was a problem hiding this comment.
Let's add something like this to the va_copy fallback body
// This fallback body exploits the fact that our codegen backends all just a plain
// memcpy to duplicate VaList. This assumption is wrong for Miri.
assert!(!cfg!(miri), "fallback body is incorrect under Miri");There was a problem hiding this comment.
We could also remove the fallback body when cfg(miri)? Or does miri use the pre-built core?
There was a problem hiding this comment.
There's no nice way to disable the body with cfg.
There was a problem hiding this comment.
This seems like a good test to run natively. Can you add //@run-native at the top of this file?
There was a problem hiding this comment.
Adding that annotation makes the test fail, without any good way to debug it. Based on https://triage.rust-lang.org/gha-logs/rust-lang/rust/81980686843 it looks like the assert is triggered, so somehow the native test sets cfg!(miri) to true but also uses the fallback?
Is there some flag I'm missing for seeing the actual cause of the failure?
There was a problem hiding this comment.
I think the cause was the other clone test also hitting the assert. Still, the debugging experience here could be better...
There was a problem hiding this comment.
This behaves exactly like regular rustc ui tests. So not sure what we could do on the debugging side.
|
Reminder, once the PR becomes ready for a review, use |
867b361 to
29c674b
Compare
29c674b to
ba67985
Compare
This comment has been minimized.
This comment has been minimized.
ba67985 to
ae93ccc
Compare
This comment has been minimized.
This comment has been minimized.
db11cc5 to
7c497ef
Compare
There was a problem hiding this comment.
I think the cause was the other clone test also hitting the assert. Still, the debugging experience here could be better...
|
@bors r+ |
This comment has been minimized.
This comment has been minimized.
c-variadic: initialize the copied `VaList` in const-eval Properly initialize the result of `VaList::clone` in `rustc_const_eval`. r? RalfJung cc @theemathas
|
💔 Test for 4f5af41 failed: CI. Failed job:
|
|
A job failed! Check out the build log: (web) (plain enhanced) (plain) Click to see the possible cause of the failure (guessed by this bot) |
|
@bors retry |
This comment has been minimized.
This comment has been minimized.
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 8c75e93 (parent) -> 4008bbd (this PR) Test differencesNo test diffs found Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 4008bbdf34b583ce44a467043aae3703afc0a76f --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (4008bbd): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)This perf run didn't have relevant results for this metric. CyclesThis perf run didn't have relevant results for this metric. Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 480.613s -> 487.822s (1.50%) |
View all comments
Properly initialize the result of
VaList::cloneinrustc_const_eval.r? RalfJung
cc @theemathas