Skip to content

[strict provenance] Rationalize "Oxford Casts"Β #95489

Open
@Gankra

Description

@Gankra

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

Oxford Casts are those that fly in the face of Harvard Architectures, and let you convert between data pointers and function pointers. In my current understanding, this affects both AVR and WASM.

For WASM, function pointers are actually indices into a ~vtable somewhere. This seems to mostly work fine and it's just a matter of "ask bad questions, get bad answers"

For AVR it causes Actual Compiler Problems that the stdlib seems to be actively routing around:

// HACK: The intermediate cast as usize is required for AVR
// so that the address space of the source function pointer
// is preserved in the final function pointer.
//
// https://github.com/avr-rust/rust/issues/143
fmt::Pointer::fmt(&(*self as usize as *const ()), f)

I do not know what "resolving" this looks like. It could involve any of:

  • just documenting the current state of affairs
  • developing a "coherent" model for what these operations do
  • fixing the compiler issues with AVR
  • forbidding oxford casts on some or all targets
  • introducing new APIs to "do it right"

I can't really help any more than this, because this is all outside my areas of expertese/motivation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-strict-provenanceArea: Strict provenance for raw pointersO-AVRTarget: AVR processors (ATtiny, ATmega, etc.)O-wasmTarget: WASM (WebAssembly), http://webassembly.org/T-langRelevant to the language 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