-
Notifications
You must be signed in to change notification settings - Fork 371
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
Detecting races when releasing Tree Borrows protectors? #3266
Comments
Cc @Vanille-N |
Oh no is this a case of "the implementation didn't support this out of the box so I didn't implement it at all" ? Of course the first fix that comes to mind is to insert around here a A possible alternative could be to give Either way if we don't want to go back on the promise that |
Good point! I am not sure if it is strictly necessary to make this a race, but just for consistency with the races on function entry it would be good to do this.
Exposing those ranges is unfortunate but not a complete blocker. We can just have a FIXME saying that in the future we might want to somehow normalize the range we send to data_race to make it not depend on RangeMap splitting/merging. |
Data race interaction with TB is an interesting question. First, notice that your code already has undefined behavior since your deallocation (even just through the fact that it acts as a write, ignoring strong protector deallocation semantics) can trigger the protector protecting the argument If we ignore this "busy wait bug," we can argue that data race detection is not needed for the protector end semantics: Any foreign write that could be racy is already accounted for by the fact that the existing protector ensures that there is no foreign write, and if there is a data race there is an interleaving where we can make the write happen before the protector ends. Similarly, if the protector end access is a write (see #3732), then any foreign read is already disabled. What adding the data race here would do is also catch data races from children, which are usually unaffected by the protector end semantics. However, I personally think that data race protection should be integrated more finely with the aliasing model. In case of Tree Borrows, I would argue that it should be a data race to concurrently access data using pointers that do not have the same tag. This would allow us to add this to the protector end accesses data race detector without having to worry about children. In general, I think that this would add very little UB (for reasons similar to the above: you can usually construct an interleaving where one write happening first makes the other write impossible). The only case where this would add UB is those involving |
IIUC in tree borrows protectors generate implicit reads when they are released. However, the data race detector doesn't seem to be aware of them. Does it make sense for these to be accesses for the data race model?
This looks like a similar issue #2648
Here is an example I tested with
MIRIFLAGS="-Zmiri-tree-borrows" cargo miri run
.The relevant code seems to be:
miri/src/borrow_tracker/tree_borrows/mod.rs
Line 109 in 13c915b
miri/src/borrow_tracker/tree_borrows/tree.rs
Line 660 in 13c915b
The text was updated successfully, but these errors were encountered: