Skip to content

miri test error: Undefined Behavior #34

@BohuTANG

Description

@BohuTANG

How to:

cargo miri test

Error:

test error::tests::parse_int_error ... ok
test error::tests::try_from_int_error ... ok
test int::cmp::tests::cmp ... ok
test int::fmt::tests::debug ... error: Undefined Behavior: attempting a write access using <146320> at alloc41000[0x4b], but that tag does not exist in the borrow stack for this location
   --> src/fmt.rs:117:13
    |
117 |             ptr::copy_nonoverlapping(lut_ptr.offset(d1), buf_ptr.offset(curr), 2);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |             |
    |             attempting a write access using <146320> at alloc41000[0x4b], but that tag does not exist in the borrow stack for this location
    |             this error occurs as part of an access at alloc41000[0x4b..0x4d]
    |
    = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
    = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
help: <146320> was created by a SharedReadWrite retag at offsets [0x0..0x1]
   --> src/fmt.rs:94:19
    |
94  |     let buf_ptr = &mut buf[0] as *mut _ as *mut u8;
    |                   ^^^^^^^^^^^
    = note: BACKTRACE (of the first span):
    = note: inside `fmt::fmt_u256` at src/fmt.rs:117:13: 117:82
note: inside `int::fmt::<impl core::fmt::Display for int::I256>::fmt`
   --> src/macros/fmt.rs:42:17
    |
42  |                   $crate::fmt::fmt_u256(n, is_nonnegative, f)
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
   ::: src/int/fmt.rs:5:1
    |
5   | / impl_fmt! {
6   | |     impl Fmt for I256;
7   | | }
    | |_- in this macro invocation
note: inside `int::fmt::<impl core::fmt::Debug for int::I256>::fmt`
   --> src/macros/fmt.rs:25:21
    |
25  |                       ::core::fmt::Display::fmt(self, f)
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
   ::: src/int/fmt.rs:5:1

Miri: https://github.com/rust-lang/miri

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