Skip to content

Miri gives an error when resolving strings #15

Closed
@jyn514

Description

@jyn514

Given the following simple use of string_interner, miri gives the error trying to reborrow for SharedReadOnly, but parent tag <2253> does not have an appropriate item in the borrow stack.

I am not quite sure what this error means, but I am concerned about possible UB in string_interner. Here is a link to a similar issue in owning-ref: rust-lang/unsafe-code-guidelines#194

use string_interner::StringInterner;

fn main() {
    let mut strings = StringInterner::default();
    let str_ref = strings.get_or_intern("hello");
    let maybe_resolved = strings.resolve(str_ref);
    println!("{}", maybe_resolved.unwrap());
}
Full miri backtrace
error: Miri evaluation error: trying to reborrow for SharedReadOnly, but parent tag <2253> does not have an appropriate item in the borrow stack
    --> /home/joshua/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/liballoc/boxed.rs:1041:9
     |
1041 |         &**self
     |         ^^^^^^^ Miri evaluation error: trying to reborrow for SharedReadOnly, but parent tag <2253> does not have an appropriate item in the borrow stack
     |
     = note: inside call to `<std::boxed::Box<str> as std::convert::AsRef<str>>::as_ref` at /home/joshua/.cargo/registry/src/proxy-git.cwkhome.fun-1ecc6299db9ec823/string-interner-0.7.1/src/lib.rs:367:30
     = note: inside call to closure at /home/joshua/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/option.rs:449:29
     = note: inside call to `std::option::Option::<&std::boxed::Box<str>>::map::<&str, [closure@DefId(14:114 ~ string_interner[4f21]::{{impl}}[12]::resolve[0]::{{closure}}[0])]>` at /home/joshua/.cargo/registry/src/proxy-git.cwkhome.fun-1ecc6299db9ec823/string-interner-0.7.1/src/lib.rs:365:9
note: inside call to `string_interner::StringInterner::<string_interner::Sym>::resolve` at src/bin.rs:6:26
    --> src/bin.rs:6:26
     |
6    |     let maybe_resolved = strings.resolve(str_ref);
     |                          ^^^^^^^^^^^^^^^^^^^^^^^^
     = note: inside call to `main` at /home/joshua/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:61:34
     = note: inside call to closure at /home/joshua/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:48:73
     = note: inside call to closure at /home/joshua/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/sys_common/backtrace.rs:136:5
     = note: inside call to `std::sys_common::backtrace::__rust_begin_short_backtrace::<[closure@DefId(1:6021 ~ std[7e82]::rt[0]::lang_start_internal[0]::{{closure}}[0]::{{closure}}[0]) 0:&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/joshua/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:48:13
     = note: inside call to closure at /home/joshua/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panicking.rs:287:40
     = note: inside call to `std::panicking::try::do_call::<[closure@DefId(1:6020 ~ std[7e82]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/joshua/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panicking.rs:282:5
     = note: inside call to `std::panicking::try::<i32, [closure@DefId(1:6020 ~ std[7e82]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe]>` at /home/joshua/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panic.rs:395:9
     = note: inside call to `std::panic::catch_unwind::<[closure@DefId(1:6020 ~ std[7e82]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/joshua/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:47:25
     = note: inside call to `std::rt::lang_start_internal` at /home/joshua/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:61:5
     = note: inside call to `std::rt::lang_start::<()>`

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