Uh oh!
There was an error while loading. Please reload this page.
Replace zeroing-on-drop with filling-on-drop. - #23535
Conversation
rust-highfive
commented
Mar 19, 2015
r? @nrc (rust_highfive has picked a reviewer for you, use r? to override) |
pnkfelix
commented
Mar 19, 2015
There was a problem hiding this comment.
Could this be a wrapper around init_dropped?
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
Oh.
I guess this might work? (it might not too.)
#[cfg(stage0)]pubunsafefndropped<T>() -> T{zeroed()}#[cfg(not(stage0))]pubunsafefndropped<T>() -> T{ intrinsics::init_dropped()}There was a problem hiding this comment.
okay i will try that tomorrow morning
There was a problem hiding this comment.
ah it works like a charm, thanks huon, now I feel dumb. :)
pnkfelix
commented
Mar 19, 2015
(@nrc notes that this PR is probably a good candidate for some run-pass-valgrind tests.) |
pnkfelix
commented
Mar 20, 2015
I may add a lint for enums using |
eddyb
commented
Mar 20, 2015
@pnkfelix IME I don't recall ever seeing |
nikomatsakis
commented
Mar 24, 2015
Oh, man, I totally missed this PR! Sorry for the delay @pnkfelix |
nikomatsakis
commented
Mar 24, 2015
r+ -- no real nits, just some questions |
pnkfelix
commented
Mar 25, 2015
@bors try |
bors
commented
Mar 25, 2015
⌛ Trying commit fc87aa8 with merge 6efae5d... |
bors
commented
Mar 25, 2015
💔 Test failed - try-bsd |
pnkfelix
commented
Mar 25, 2015
@bors try |
bors
commented
Mar 25, 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]`.
bors
commented
Mar 25, 2015
💔 Test failed - try-mac |
Manishearth
commented
Mar 26, 2015
|
pnkfelix
commented
Mar 26, 2015
bors
commented
Mar 26, 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]`.
bors
commented
Mar 26, 2015
💔 Test failed - try-mac |
Refactored code so that the drop-flag values for initialized (`DTOR_NEEDED`) versus dropped (`DTOR_DONE`) are given explicit names. Add `mem::dropped()` (which with `DTOR_DONE == 0` is semantically the same as `mem::zeroed`, but the point is that it abstracts away from the particular choice of value for `DTOR_DONE`). Filling-drop needs to use something other than `ptr::read_and_zero`, so I added such a function: `ptr::read_and_drop`. But, libraries should not use it if they can otherwise avoid it. Fixes to tests to accommodate filling-drop.
…ile-fail tests. (I.e. the idea being, lets catch errors in these basic constructs sometime *before* we start doing the doc tests.)
bors
commented
Mar 26, 2015
bors
commented
Mar 26, 2015
☀️ Test successful - try-bsd, try-linux, try-mac, try-win-32, try-win-64 |
pnkfelix
commented
Mar 26, 2015
bors
commented
Mar 26, 2015
⌛ Testing commit e2cc8b1 with merge b50bf4a... |
bors
commented
Mar 26, 2015
💔 Test failed - auto-mac-64-opt |
pnkfelix
commented
Mar 27, 2015
bors
commented
Mar 27, 2015
⌛ Testing commit b68ca84 with merge 74ab665... |
bors
commented
Mar 27, 2015
💔 Test failed - auto-win-64-nopt-t |
pnkfelix
commented
Mar 27, 2015
@bors retry |
bors
commented
Mar 27, 2015
⌛ Testing commit b68ca84 with merge be7f6ac... |
bors
commented
Mar 27, 2015
💔 Test failed - auto-win-32-nopt-t |
alexcrichton
commented
Mar 27, 2015
@bors: retry On Fri, Mar 27, 2015 at 10:59 AM, bors notifications@github.com wrote:
|
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]`.
bors
commented
Mar 28, 2015
⌛ Testing commit b68ca84 with merge 46fa43d... |
pnkfelix
commented
Jun 5, 2015
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 |
eddyb
commented
Jun 5, 2015
@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? |
pnkfelix
commented
Jun 5, 2015
@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. |
eddyb
commented
Jun 5, 2015
@alexcrichton's |
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].