-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
BinaryHeap is not exception safe #25842
Labels
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
Comments
My immediate ideas are one of
|
Long ago I suggested two other strategies:
|
triage: I-nominated, T-libs |
I'm trying gankro's panic guard idea. |
bluss
pushed a commit
to bluss/rust
that referenced
this issue
May 28, 2015
Use a struct called Hole that keeps track of an invalid location in the vector and fills the hole on drop. I include a run-pass test that the current BinaryHeap fails, and the new one passes. Fixes rust-lang#25842
bluss
pushed a commit
to bluss/rust
that referenced
this issue
May 28, 2015
Use a struct called Hole that keeps track of an invalid location in the vector and fills the hole on drop. I include a run-pass test that the current BinaryHeap fails, and the new one passes. Fixes rust-lang#25842
bluss
pushed a commit
to bluss/rust
that referenced
this issue
May 28, 2015
Use a struct called Hole that keeps track of an invalid location in the vector and fills the hole on drop. I include a run-pass test that the current BinaryHeap fails, and the new one passes. Fixes rust-lang#25842
bluss
pushed a commit
to bluss/rust
that referenced
this issue
May 28, 2015
Use a struct called Hole that keeps track of an invalid location in the vector and fills the hole on drop. I include a run-pass test that the current BinaryHeap fails, and the new one passes. Fixes rust-lang#25842
bors
added a commit
that referenced
this issue
May 28, 2015
collections: Make BinaryHeap panic safe in sift_up / sift_down Use a struct called Hole that keeps track of an invalid location in the vector and fills the hole on drop. I include a run-pass test that the current BinaryHeap fails, and the new one passes. NOTE: The BinaryHeap will still be inconsistent after a comparison fails. It will not have the heap property. What we fix is just that elements will be valid values. This is actually a performance win -- the new code does not bother to write in `zeroed()` values in the holes, it just leaves them as they were. Net result is something like a 5% decrease in runtime for `BinaryHeap::from_vec`. This can be further improved by using unchecked indexing (I confirmed it makes a difference, not a surprise with the non-sequential access going on), but let's leave that for another PR. Safety first 😉 Fixes #25842
XMPPwocky
pushed a commit
to XMPPwocky/rust
that referenced
this issue
May 29, 2015
Use a struct called Hole that keeps track of an invalid location in the vector and fills the hole on drop. I include a run-pass test that the current BinaryHeap fails, and the new one passes. Fixes rust-lang#25842
alexcrichton
pushed a commit
to alexcrichton/rust
that referenced
this issue
Jun 10, 2015
Use a struct called Hole that keeps track of an invalid location in the vector and fills the hole on drop. I include a run-pass test that the current BinaryHeap fails, and the new one passes. Fixes rust-lang#25842
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
BinaryHeap is using
zeroed()
and may not be exception safe. I.e. it is in an inconsistent state after being recovered after panic. See issue #25662 and others.Relevant code is BinaryHeap::sift_up, sift_down_range
cc @cmr
The text was updated successfully, but these errors were encountered: