-
Notifications
You must be signed in to change notification settings - Fork 13.6k
fix handling of base address for TypeId allocations #144187
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing really changes here, but I looked at the code to ensure it is correct for TypeId and realized some ways in which it, and the comments, could be improved.
This comment has been minimized.
This comment has been minimized.
31b35e0
to
2ad5678
Compare
Is it intentional that this PR does not fix the |
Yes, catching UB is not a requirement for CTFE as it has significant impact on compile times. A program that does UB if two type ids do not match may suddenly stop erroring with the next compiler release, or error even if the type ids match. |
Also, you can't use it to get a |
2ad5678
to
3f9be40
Compare
#144169 landed so this PR is no longer blocked. |
@bors r+ rollup |
fix handling of base address for TypeId allocations This fixes the problems discovered by `@theemathas` in rust-lang#142789: - const-eval would sometimes consider TypeId pointers to be null - the type ID is different in Miri than in regular executions Both boil down to the same issue: the TypeId "allocation" has a guaranteed 0 base address, but const-eval assumes it was non-zero (like normal allocations) and Miri randomized it (like normal allocations). r? `@oli-obk`
fix handling of base address for TypeId allocations This fixes the problems discovered by ``@theemathas`` in rust-lang#142789: - const-eval would sometimes consider TypeId pointers to be null - the type ID is different in Miri than in regular executions Both boil down to the same issue: the TypeId "allocation" has a guaranteed 0 base address, but const-eval assumes it was non-zero (like normal allocations) and Miri randomized it (like normal allocations). r? ``@oli-obk``
fix handling of base address for TypeId allocations This fixes the problems discovered by ```@theemathas``` in rust-lang#142789: - const-eval would sometimes consider TypeId pointers to be null - the type ID is different in Miri than in regular executions Both boil down to the same issue: the TypeId "allocation" has a guaranteed 0 base address, but const-eval assumes it was non-zero (like normal allocations) and Miri randomized it (like normal allocations). r? ```@oli-obk```
Rollup of 15 pull requests Successful merges: - #142097 (gpu offload host code generation) - #143430 (Lower extra lifetimes before normal generic params.) - #143672 (Fix Box allocator drop elaboration) - #143768 (Constify Try, From, TryFrom and relevant traits) - #143816 (Implement `check` for compiletest and RA using tool macro) - #143985 (rustc_public: de-StableMIR-ize) - #144027 (clippy: make tests work in stage 1) - #144080 (Mitigate `#[align]` name resolution ambiguity regression with a rename) - #144176 (Add approval blocking labels for new bors) - #144187 (fix handling of base address for TypeId allocations) - #144212 (Remove the ptr_unique lang item) - #144243 (Subtree update of `rust-analyzer`) - #144246 (Don't use another main test file as auxiliary) - #144251 (rustc-dev-guide subtree update) - #144254 (opt-dist: make `artifact-dir` an absolute path for `opt-dist local`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 14 pull requests Successful merges: - #142097 (gpu offload host code generation) - #143430 (Lower extra lifetimes before normal generic params.) - #143768 (Constify Try, From, TryFrom and relevant traits) - #143816 (Implement `check` for compiletest and RA using tool macro) - #143985 (rustc_public: de-StableMIR-ize) - #144027 (clippy: make tests work in stage 1) - #144080 (Mitigate `#[align]` name resolution ambiguity regression with a rename) - #144176 (Add approval blocking labels for new bors) - #144187 (fix handling of base address for TypeId allocations) - #144212 (Remove the ptr_unique lang item) - #144243 (Subtree update of `rust-analyzer`) - #144246 (Don't use another main test file as auxiliary) - #144251 (rustc-dev-guide subtree update) - #144254 (opt-dist: make `artifact-dir` an absolute path for `opt-dist local`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #144187 - RalfJung:type-id-base-addr, r=oli-obk fix handling of base address for TypeId allocations This fixes the problems discovered by ````@theemathas```` in #142789: - const-eval would sometimes consider TypeId pointers to be null - the type ID is different in Miri than in regular executions Both boil down to the same issue: the TypeId "allocation" has a guaranteed 0 base address, but const-eval assumes it was non-zero (like normal allocations) and Miri randomized it (like normal allocations). r? ````@oli-obk````
Rollup of 14 pull requests Successful merges: - rust-lang/rust#142097 (gpu offload host code generation) - rust-lang/rust#143430 (Lower extra lifetimes before normal generic params.) - rust-lang/rust#143768 (Constify Try, From, TryFrom and relevant traits) - rust-lang/rust#143816 (Implement `check` for compiletest and RA using tool macro) - rust-lang/rust#143985 (rustc_public: de-StableMIR-ize) - rust-lang/rust#144027 (clippy: make tests work in stage 1) - rust-lang/rust#144080 (Mitigate `#[align]` name resolution ambiguity regression with a rename) - rust-lang/rust#144176 (Add approval blocking labels for new bors) - rust-lang/rust#144187 (fix handling of base address for TypeId allocations) - rust-lang/rust#144212 (Remove the ptr_unique lang item) - rust-lang/rust#144243 (Subtree update of `rust-analyzer`) - rust-lang/rust#144246 (Don't use another main test file as auxiliary) - rust-lang/rust#144251 (rustc-dev-guide subtree update) - rust-lang/rust#144254 (opt-dist: make `artifact-dir` an absolute path for `opt-dist local`) r? `@ghost` `@rustbot` modify labels: rollup
This fixes the problems discovered by @theemathas in #142789:
Both boil down to the same issue: the TypeId "allocation" has a guaranteed 0 base address, but const-eval assumes it was non-zero (like normal allocations) and Miri randomized it (like normal allocations).
r? @oli-obk