-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Description
Tracking issue for Ref::map_split
and RefMut::map_split
(feature refcell_map_split
), implemented in #51466.
Blocking stabilization
- Performance (Optimize RefCell refcount tracking #51630)Proof of soundness (Add Ref/RefMut map_split method #51466 (comment))To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Metadata
Metadata
Assignees
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
RalfJung commentedon Jun 19, 2018
Can I just say how awesome it is for people to actually be willing to block something on a proof of soundness? I love this community <3
jhjourdan commentedon Sep 21, 2018
I have just completed the proof of soundness of this new feature:
https://gitlab.mpi-sws.org/FP/LambdaRust-coq/commit/70db5cbf1f63879ff8171218d4ba679e8e4c69a2
Note, however, that our model do not model machine integer. Therefore, it is possible that our proof would not spot an overflow in the borrow counter that would cause an unsoundness. That said, causing an overflow in the borrow counter is very hard anyway.
joshlf commentedon Sep 21, 2018
That's fantastic! Thanks so much for doing that! In your opinion, is integer overflow something we should be concerned about, or are you comfortable that it's not an issue even though the proof doesn't technically cover it?
@joshtriplett @dtolnay Anything left to do before proposing stabilization?
joshtriplett commentedon Sep 21, 2018
Given recent events, I think it's rather reasonable to want to carefully examine the assumptions that integer overflow can't happen here.
Looking over the code, it appears that several of the overflow checks occur in a
debug_assert!
rather than anassert!
, for instance.jhjourdan commentedon Sep 21, 2018
Of course, a thorough review of the code cannot hurt. But actually, I cannot imagine a realistic scenario where this overflow would occur without causing an out of memory first (or using a lot of mem::forget calls for each of the created Ref/RefMut, which is also a weird thing to do).
jhjourdan commentedon Sep 21, 2018
What overflow check are you speaking about? Reading the current state of the code, all the overflow checks are either
is_reading(...)
oris_writing(...)
orself.borrow.get() == UNUSED
, none of which check for overflow.As far as I can tell, each incrementation or decrementation of the counter in this code is either guarded by an overflow check or cannot overflow because of the current sate of the counter.
joshlf commentedon Sep 21, 2018
Unsoundness is unsoundness, regardless of how pathological the program would have to be :)
But regardless, I don't think it's an issue. All overflow is checked by
assert!
s. Thedebug_assert!
s only check for conditions which we, the programmers, believe should always be true. In particular:BorrowRef::drop
, and asserts that the borrow is a reading borrow.BorrowRef
is a reading borrow, so if it weren't true, it'd be a bug.BorrowRef::clone
, and asserts that the borrow is a reading borrow. It's safe for the same reason as the previous one.BorrowRefMut::drop
andBorrowRefMut::clone
respectively, check that the borrow is a writing borrow, and are safe for the same reason.joshtriplett commentedon Sep 21, 2018
@joshlf Thanks for clarifying! With that clarification on the
debug_assert!
calls, this LGTM.joshtriplett commentedon Sep 21, 2018
That said: could someone add a note to the comment at the top of that file, regarding checking for overflow, that any such overflow checks must be
assert!
and notdebug_assert!
, just to make it less likely that future changes accidentally make that mistake?Centril commentedon Nov 10, 2018
@sfackler shall we stabilize this perhaps?
SimonSapin commentedon Jan 18, 2019
We previously had
Ref::filter_map
and removed it in #27746. Ifmap_split
is deemed useful enough for inclusion in the standard library, shouldfilter_map
be brought back? @rust-lang/libs what do you think?16 remaining items
Centril commentedon Mar 6, 2019
Ping @Kimundi @sfackler @withoutboats :)
rfcbot commentedon Mar 6, 2019
🔔 This is now entering its final comment period, as per the review above. 🔔
rfcbot commentedon Mar 16, 2019
The final comment period, with a disposition to merge, as per the review above, is now complete.
As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.
The RFC will be merged soon.
Rollup merge of rust-lang#59280 - joshlf:sandbox/joshlf/stabilize-ref…
Rollup merge of rust-lang#59280 - joshlf:sandbox/joshlf/stabilize-ref…