Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upReplace zeroing-on-drop with filling-on-drop. #23535
Conversation
rust-highfive
assigned
nrc
Mar 19, 2015
This comment has been minimized.
This comment has been minimized.
|
r? @nrc (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
rust-highfive
assigned
nikomatsakis
and unassigned
nrc
Mar 19, 2015
huonw
reviewed
Mar 19, 2015
| /// to non-zeroing drop. | ||
| #[inline] | ||
| #[unstable(feature = "filling_drop")] | ||
| pub unsafe fn dropped<T>() -> T { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
pnkfelix
Mar 19, 2015
Author
Member
I tried to make it such a wrapper at one point in the history of the PR, but I got tired of trying to work out the staging issues involved...
This comment has been minimized.
This comment has been minimized.
huonw
Mar 19, 2015
Member
Oh.
I guess this might work? (it might not too.)
#[cfg(stage0)]
pub unsafe fn dropped<T>() -> T { zeroed() }
#[cfg(not(stage0))]
pub unsafe fn dropped<T>() -> T { intrinsics::init_dropped() }
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
(@nrc notes that this PR is probably a good candidate for some run-pass-valgrind tests.) |
Manishearth
referenced this pull request
Mar 20, 2015
Closed
Remove rt::default_sched_threads and RUST_THREADS. #23534
This comment has been minimized.
This comment has been minimized.
|
I may add a lint for enums using |
This comment has been minimized.
This comment has been minimized.
|
@pnkfelix IME I don't recall ever seeing |
This comment has been minimized.
This comment has been minimized.
|
Oh, man, I totally missed this PR! Sorry for the delay @pnkfelix |
This comment has been minimized.
This comment has been minimized.
|
r+ -- no real nits, just some questions |
This comment has been minimized.
This comment has been minimized.
|
@bors try |
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Mar 25, 2015
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@bors try |
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Mar 25, 2015
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
pnkfelix
force-pushed the
pnkfelix:fsk-filling-drop
branch
from
94392c8
to
fd65e4f
Mar 26, 2015
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Mar 26, 2015
This comment has been minimized.
This comment has been minimized.
|
|
pnkfelix
added some commits
Feb 10, 2015
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Mar 26, 2015
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Mar 27, 2015
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@bors retry |
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Mar 27, 2015
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@bors: retry On Fri, Mar 27, 2015 at 10:59 AM, bors notifications@github.com wrote:
|
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this pull request
Mar 27, 2015
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Mar 28, 2015
bors
merged commit b68ca84
into
rust-lang:master
Mar 28, 2015
This was referenced May 26, 2015
This comment has been minimized.
This comment has been minimized.
|
Note: #26025 points out a potential bug injected by filling-drop; namely, there is a switch on the discriminant of an enum, which will now be set to a value outside the range of typical discriminants, and ends up jumping into an |
This comment has been minimized.
This comment has been minimized.
|
@pnkfelix but wouldn't there be a check for that value before the match on the discriminant? When I suggested the "poke as little to disable all possible dtors" interim solution, enum variants were the interesting case, because you could search for a variant with little (or no, e.g. Is that viable at all here? Or since this is a temporary measure, after all, maybe just add a case for the discriminant being filled with the value - but what if it's a valid discriminant for that enum? |
This comment has been minimized.
This comment has been minimized.
|
@eddyb we might need to add such a check-before-switch if filling-drop stays as it is today. But historically, as I understand it from what niko tells me, we were relying on the fact that every enum that could implement I don't know how viable it would be to attempt to fill with a "valid" enum variant. It seems sort of sketchy to me; it would require the filling code to be more aware of structural layout than it is today... I'd prefer to invest effort in finishing nonzeroing drop. |
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton's |
pnkfelix commentedMar 19, 2015
Replace zeroing-on-drop with filling-on-drop.
This is meant to set the stage for removing all zeroing and filling (on drop) in the future.
Note that the code is meant to be entirely abstract with respect to the particular values used for the drop flags: the final commit demonstrates how to go from zeroing-on-drop to filling-on-drop by changing the value of three constants (in two files).
See further discussion on the internals thread:
http://internals.rust-lang.org/t/attention-hackers-filling-drop/1715/11
[breaking-change] especially for structs / enums using
#[unsafe_no_drop_flag].