Skip to content

[strict provenance] make panic_unwind conform #95494

Open
@Gankra

Description

@Gankra

This issue is part of the Strict Provenance Experiment - #95228

The panic_unwind component is full of lots of pointer provenance crimes.

In particular, I noticed that dwarf/eh.rs is just a complete hairball of uniformly mixing pointers and integers:

unsafe fn read_encoded_pointer(
reader: &mut DwarfReader,
context: &EHContext<'_>,
encoding: u8,
) -> Result<usize, ()> {

And seh.rs has some sketchy stuff too:

macro_rules! ptr {
(0) => (0);
($e:expr) => {
(($e as usize) - (&imp::__ImageBase as *const _ as usize)) as u32
}
}

I ran into this fairly early, so these seemed like pretty overwhelmingly hard problems at the time, but with a bit of time to sleep on it I think it might be possible to fix a lot of this by just making everything be pointers by default and then if you "notice" something is actually an offset, only cast it to an integer at that point.

In general it's ok for integers to pretend to be pointers "for fun", and if anything is ever int | ptr the valid union of these types is ptr.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)A-strict-provenanceArea: Strict provenance for raw pointersO-windowsOperating system: WindowsT-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