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
{{ message }}
Repository navigation
Miri checks ptr.read() but not dereferencing a pointer (*ptr) #1526
I just tried on the playground, and I do get an error for the second example as well:
error: Undefined Behavior: trying to reborrow for SharedReadOnly, but parent tag <untagged> does not have an appropriate item in the borrow stack
--> src/main.rs:5:24
|
5 | println!("{}", *b.add(1));
| ^^^^^^^^^ trying to reborrow for SharedReadOnly, but parent tag <untagged> 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
This has nothing to do with deref vs read. This is caused by is_empty creating a raw pointer and Stacked Borrows not tracking raw pointers in detail -- so it "confuses" the raw pointer created there with b. That is currently expected behavior, though I would like to do more precise tracking of raw pointers eventually (but this might completely kill performance... and we'll have to see how compatible it is with real code).
@RalfJung Yes. this is a completely different issue than what I was describing,
what happened is that I had a complex function, saw that it didn't error, I removed a lot of code, replaced with read() and it did, so I wrongly assumed it was the read() change. sorry.
So together with my confusion and the fact that this is expected behavior I'll close this issue.
if you're curious this was the code snippet that got me here: rust-lang/rust#75943 (trying to minimize that down in the playground got me to accidentally assume deref was the problem)
Activity
RalfJung commentedon Aug 26, 2020
I just tried on the playground, and I do get an error for the second example as well:
elichai commentedon Aug 26, 2020
Ha, you're right, this is weird.
This on the other hand doesn't give an error:
RalfJung commentedon Aug 26, 2020
But neither does this:
RalfJung commentedon Aug 26, 2020
This has nothing to do with deref vs
read. This is caused byis_emptycreating a raw pointer and Stacked Borrows not tracking raw pointers in detail -- so it "confuses" the raw pointer created there withb. That is currently expected behavior, though I would like to do more precise tracking of raw pointers eventually (but this might completely kill performance... and we'll have to see how compatible it is with real code).elichai commentedon Aug 26, 2020
@RalfJung Yes. this is a completely different issue than what I was describing,
what happened is that I had a complex function, saw that it didn't error, I removed a lot of code, replaced with
read()and it did, so I wrongly assumed it was theread()change. sorry.elichai commentedon Aug 26, 2020
So together with my confusion and the fact that this is expected behavior I'll close this issue.
if you're curious this was the code snippet that got me here: rust-lang/rust#75943 (trying to minimize that down in the playground got me to accidentally assume deref was the problem)
RalfJung commentedon Aug 26, 2020
I opened rust-lang/unsafe-code-guidelines#248 to track the underlying problem.
Rollup merge of rust-lang#75943 - elichai:2020-align_offset-docs, r=R…