You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let tls = std::sync::Arc::new(ThreadLocal::new());let s = tls.get_or(|| "Hello World".to_owned());let thread_tls = tls.clone();
std::thread::spawn(move || {
thread_tls.get_or(String::new);}).join().unwrap();
tls.get().unwrap();
s;
Produces undefined behavior when run through Miri:
error: Undefined Behavior: trying to reborrow for SharedReadOnly, but parent tag <234426> does not have an appropriate item in the borrow stack
--> src/main.rs:17:5
|
17 | s;
| ^ trying to reborrow for SharedReadOnly, but parent tag <234426> does not have an appropriate item in the borrow stack
|
= help: this indicates a potential bug in the program: it performed an invalid operation, but the 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
I think this is caused by moving the data to the current hash map in the get_slow path. If I do not move it to the current hash map and instead just get it directly, this UB does not occur.
The text was updated successfully, but these errors were encountered:
The following program:
Produces undefined behavior when run through Miri:
I think this is caused by moving the data to the current hash map in the
get_slow
path. If I do not move it to the current hash map and instead just get it directly, this UB does not occur.The text was updated successfully, but these errors were encountered: