Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

miri test error: Undefined Behavior #34

Open
BohuTANG opened this issue Nov 7, 2023 · 1 comment
Open

miri test error: Undefined Behavior #34

BohuTANG opened this issue Nov 7, 2023 · 1 comment

Comments

@BohuTANG
Copy link

BohuTANG commented Nov 7, 2023

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

@nlordell
Copy link
Owner

nlordell commented Nov 7, 2023

Thanks for bringing this up! Will investigate. It looks related to the fmt implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants