Skip to content

Miri: refactor handling of "uncanonical" AllocIds #71194

Closed
@RalfJung

Description

@RalfJung

There are (at least) two situations where Miri uses a different AllocId for allocations than would be used in already created "global" allocations:

  • extern static are supported by mapping them to another, existing allocation.
  • TLS statics need a different AllocId for each thread.

Currently both of these use different systems, and the extern static system has some disadvantages like not erroring on this program:

extern {
    static mut TEST: i32;
}

fn main() {
    let _x = unsafe { &TEST };
}

We should use the same system for both, and that system should be to do whatever adjustments we need to do when converting Pointer<()> (an untagged pointer, in global tcx memory) to Pointer<M::PointerTag>.

With #70685 resolved we might not need this for TLS statics any more, depending on the solution. But it would still be good to do this for extern static. Either way, as part of this we should also cleanup the TLS static handling in Miri, which currently special-cases ConstValue::Scalar being converted into Miri machine values -- we should do the right thing for all pointers in constants/globals.

Cc @oli-obk

Metadata

Metadata

Assignees

Labels

A-miriArea: The miri toolC-cleanupCategory: PRs that clean code up or issues documenting cleanup.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions