Skip to content

Miri detects UB on tests when using --features global #51

@MortenLohne

Description

@MortenLohne

MIRIFLAGS="-Zmiri-tree-borrows" cargo miri test --features global immediately detects UB:

error: Undefined Behavior: read access through <52087> at alloc597[0x24a8] is forbidden
    --> /home/morten/dev/dlmalloc-rs/src/dlmalloc.rs:1725:9
     |
1725 |         (*me).head & !FLAG_BITS
     |         ^^^^^^^^^^ Undefined Behavior occurred here
     |
     = help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
     = help: the accessed tag <52087> has state Disabled which forbids this child read access
     = help: the accessed tag <52087> was created here, in the initial state Reserved
help: the accessed tag <52087> later transitioned to Disabled due to a foreign write access at offsets [0x24a8..0x24b0]
    --> /home/morten/dev/dlmalloc-rs/src/dlmalloc.rs:1745:9
     |
1745 |         (*me).head &= !PINUSE;
     |         ^^^^^^^^^^^^^^^^^^^^^
     = help: this transition corresponds to a loss of read and write permissions

Running miri with stacked borrows also reports UB. It looks like the tests have never been run under miri with --features global enabled before, which makes most of the tests run with the platform's default allocator instead. I have made #52 to address this.

I discovered this when investigating rust-lang/rust#144199, although this may be a different issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions