-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nondeterminism encountered when writing metadata for ProvenanceMap #124306
Comments
Is it possible to dig out which AllocIds are in the unstable ProvenanceMap? That could help point to the |
ProvenanceMap contains AllocId which are very global state - a const eval query will just ask for the "next free allocid" on a bunch of occasions. So any nondet in processing order anywhere in the compiler can surface here.
Also, in the parallel compiler I assume this is fundamentally nondet. I don't think we have anything in place that would ensure concurrently executed queries obtain allocid in a deterministic manner.
(I have no idea how allocid are stored in metadata so not sure if this is evem relevant.)
|
I'm growing suspicious that this isn't the ProvenanceMap at all, because the nondeterministic bytes contain strings, and there doesn't seem to be anything in the encoding that would imply that. Moreover, I grepped the source for any strings I saw, and there was a common thread. Every one of them was in a doc link inside of a doc comment, like: The strings I searched for:
|
That's probably the imprecision that I was worried about 😭 |
they aren't stored. We store their
Since we encode the actual allocation instead of an id, you will see strings in there if the const allocations constain strings (e.g. due to being part of string literals or something from formatting/panicking infrastructure). |
I don't see how But, if the layout of whatever Rust type (from your code, not from the compiler) is stored here is changing, then the allocation would change, too. |
they aren't stored. We store their GlobalAlloc and regenerate new ids on loading from metadata.
But how is allocation identity encoded? As in, how does it distinguish between two different allocs with the same content vs two references to the same alloc?
|
edit (as the scheme changed over the years) We create a table of allocations during encoding and make all alloc ids be indices into that table. |
Okay so they are still some sort of ID, but separate from the AllocId we see in the in-memory data structure. |
After some fixes to the RUSTC_FILE_ENCODER_PANIC_AT_OFFSET implementation I'm closing this in favor of #124357, which has the correct backtrace. Sorry for the noise. |
Fuchsia has a test that checks whether rustc output is deterministic, and we find that it fairly reliably shifts bytes around in the metadata output for the
ProvenanceMap
for one particular crate in our build.I determined this by picking out some changes of d5bd169 to add
RUSTC_FILE_ENCODER_PANIC_AT_OFFSET
and examining the backtrace at a number of offsets that differ in one failure in the hexdump below.cc @RalfJung @oli-obk, are there any obvious places to look for sources of nondeterminism?
Lines are from compiler commit 7f2fc33. Source code is available here.
Full backtrace
The text was updated successfully, but these errors were encountered: