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

Undefined Behavior with im::OrdSet #207

Open
JustForFun88 opened this issue Feb 4, 2023 · 1 comment
Open

Undefined Behavior with im::OrdSet #207

JustForFun88 opened this issue Feb 4, 2023 · 1 comment

Comments

@JustForFun88
Copy link

If you try run this code:

fn main() {
    let iter = (0..11).map(|x| x.to_string());
    let container = iter.collect::<im::OrdSet<String>>();
}

with

cargo miri run

it causes:

error: Undefined Behavior: attempting a read access using <20271> at alloc2231[0x40], but that tag does not exist in the borrow stack for this location
   --> C:\Users\user\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\sized-chunks-0.6.5\src\sized_chunk\mod.rs:289:13
    |
289 |             ptr::copy(chunk.ptr(from), chunk.mut_ptr(to), count)
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |             |
    |             attempting a read access using <20271> at alloc2231[0x40], but that tag does not exist in the borrow stack for this location
    |             this error occurs as part of an access at alloc2231[0x40..0x100]
    |
    = 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: <20271> was created by a SharedReadOnly retag at offsets [0x10..0x610]
   --> src\main.rs:3:21
    |
3   |     let container = iter.collect::<im::OrdSet<String>>();
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: <20271> was later invalidated at offsets [0x10..0x620] by a Unique FnEntry retag inside this call
   --> src\main.rs:3:21
    |
3   |     let container = iter.collect::<im::OrdSet<String>>();
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: BACKTRACE:
    = note: inside `sized_chunks::sized_chunk::Chunk::<im::ordset::Value<std::string::String>>::force_copy` at C:\Users\user\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\sized-chunks-0.6.5\src\sized_chunk\mod.rs:289:13
    = note: inside `sized_chunks::sized_chunk::Chunk::<im::ordset::Value<std::string::String>>::insert` at C:\Users\user\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\sized-chunks-0.6.5\src\sized_chunk\mod.rs:567:17
    = note: inside `im::nodes::btree::Node::<im::ordset::Value<std::string::String>>::insert` at C:\Users\user\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\im-15.1.0\./src\nodes\btree.rs:607:29
    = note: inside `im::OrdSet::<std::string::String>::insert` at C:\Users\user\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\im-15.1.0\./src\ord\set.rs:494:19        
    = note: inside `<im::OrdSet<std::string::String> as std::iter::FromIterator<std::string::String>>::from_iter::<std::iter::Map<std::ops::Range<i32>, [closure@src\main.rs:2:28: 2:31]>>` at C:\Users\user\.cargo\registry\src\gh.neting.cc-1ecc6299db9ec823\im-15.1.0\./src\ord\set.rs:1070:13
    = note: inside `<std::iter::Map<std::ops::Range<i32>, [closure@src\main.rs:2:28: 2:31]> as std::iter::Iterator>::collect::<im::OrdSet<std::string::String>>` at C:\Users\user\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\iter\traits\iterator.rs:1836:9
note: inside `main` at src\main.rs:3:21
   --> src\main.rs:3:21
    |
3   |     let container = iter.collect::<im::OrdSet<String>>();
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to previous error; 1 warning emitted
@raiscui
Copy link

raiscui commented Feb 22, 2023

same for me

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