Uh oh!
There was an error while loading. Please reload this page.
UB free test for CString Drop - #36607
Conversation
rust-highfive
commented
Sep 21, 2016
(rust_highfive has picked a reviewer for you, use r? to override) |
nagisa
commented
Sep 21, 2016
The benchmark was in |
matklad
commented
Sep 21, 2016
Source code: https://gist.github.com/matklad/87a77a7670b1b9144e09b9c4e62ea00f Two runs without two runs with volatile write (this PR): Will try to add a non volatile write bench later. Is there a faster way to build stdlib than |
matklad
commented
Sep 22, 2016
Here's the one with non-volatile write (no perceivable difference with volatile): |
matklad
commented
Sep 22, 2016
Also it may make sense to compare these to the cost of the allocation, because the overhead kinda amortizes between |
alexcrichton
commented
Sep 25, 2016
I don't think it's worth using a volatile write to try to fix this test, it's just an opportunistic thing we do and if LLVM decides to remove it then that seems like a good thing. (it won't do so in debug mode, especially if we If the test causes problems then I think it's safe to remove, it's probably not worth having a super elaborate test case for this. |
matklad
commented
Sep 25, 2016
The test works fine without
Yes indeed. So I'll add |
matklad
commented
Sep 26, 2016
Remove CString drop test. The test relies on the undefined behavior, and so may fail in some circumstances. This can be worked around by stubbing a memory allocator in the test, but it is a bit of work, and LLVM could still theoretically eliminate the write of the zero byte in release mode (which is intended). So let's just remove the test and mark the function as inline. It shouldn't be optimized away when inlined into the debug build of user's code. Supersedes rust-lang#36607 r? @alexcrichton
This implements an UB free (I hope :) ) test for #36264. Thanks to @petrochenkov and @nagisa for advice.
It also switched to
volatile_writefor zeroing per @Amanieu suggestion, which should prevent LLVM from optimizing our efforts away. @nagisa could you re-run your benchmark with this implementation to see if anything has changed?