-
Notifications
You must be signed in to change notification settings - Fork 51
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 UB in Arc::inner
using Arc::clone
#38
Comments
Hmmm. triomphe was written before a lot of the niceties for doing pointer stuff existed. I don't have the time to figure this out, but I suspect whatever operation we're doing there is one that can be done safely; we're not doing much different from what std's Arc does. |
Also, your crate is doing a lot of pointer into/from raw stuff, any chance you can make a minimal example that doesn't involve your crate? |
Usually this means that the pointer was used outside the range of memory that the tag is valid for. If the tag is valid for You are not the first to be taken off-guard by this. We should probably include memory ranges in those messages, to make this less confusing. |
pointer tag tracking: on creation, log the offsets it is created for Hopefully this makes things like Manishearth/triomphe#38 easier to diagnose.
pointer tag tracking: on creation, log the offsets it is created for Hopefully this makes things like Manishearth/triomphe#38 easier to diagnose.
pointer tag tracking: on creation, log the offsets it is created for Hopefully this makes things like Manishearth/triomphe#38 easier to diagnose.
Thank you both (and also @saethlin) for your kind responses and for being so quick to address this issue.
@RalfJung I see you already implemented this. As a small addendum, I also opened rust-lang/miri#2316 to clarify the README regarding the tracking flag. I think part of why I was confused is that right now it only mentions tag invalidation as its effect, which contributed to my feeling that somehow output was missing from miri. |
Clarify the effect of the `-Zmiri-track-pointer-tag` flag in the README Edit the README to explicitly say that the `-Zmiri-track-pointer-tag` flag also tracks the creation of tags, not just when they are popped/invalidated. Related to #2308 / Manishearth/triomphe#38.
I'm using
triomphe
for thecstree
library, a fork of@matklad
'srowan
syntax tree library used inrust-analyzer
. With the latest nightly,miri
emits an error for potential undefined behaviour for the reborrow inArc::inner
.The reborrow occurs while
Arc::clone
ing a pointer obtained fromArc::new
. In the specific instance posted below, it is triggered by thesytax::text::tests::test_text_equality
, but I've ran it against other tests and the error is very reproducible in any test that builds a syntax tree.There were a few
miri
warnings on thecstree
side related to the relatively recent strict provenance development, which I addressed, so only the reborrow remains.Full Backtrace
I've also ran
miri
again with-Zmiri-track-pointer-tag=232138
, which curiously (to me, as a definite non-expert onmiri
) only shows where the tag is created (which is inArc::into_raw
when constructing thecstree::GreenToken::new
) and no pop/tag invalidation (note that there is also no diagnostic note about invalidation in the error), so potentially this could also be Miri misfiring?Tracking Info
Nightly version:
rustc 1.64.0-nightly (7425fb293 2022-06-30)
.Worked with
rustc 1.63.0-nightly (76761db59 2022-05-24)
.The text was updated successfully, but these errors were encountered: