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 updebug_assert to ensure that from_raw_parts is only used properly aligned #52972
Conversation
rust-highfive
assigned
shepmaster
Aug 2, 2018
This comment has been minimized.
This comment has been minimized.
|
r? @shepmaster (rust_highfive has picked a reviewer for you, use r? to override) |
rust-highfive
added
the
S-waiting-on-review
label
Aug 2, 2018
This comment has been minimized.
This comment has been minimized.
|
So just to be clear, this can probably not be merged right now because it fails the ripgrep test suite on Windows:
However, I was unable to reproduce this on Linux. Cc @BurntSushi |
This comment has been minimized.
This comment has been minimized.
|
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
This comment has been minimized.
This comment has been minimized.
|
Oh dang, we test codegen even with debug assertions and somehow this used to work but now it cannot optimize away these alignment tests? This is basically the inverse problem of not having debug assertions in user builds -- with |
This comment has been minimized.
This comment has been minimized.
|
@RalfJung Is there a way to get a full backtrace? I don't think I can do much with the given info. And this is only failing on Windows but not other platforms? I'm trying to think where there might even be a I can't immediately spot the error by inspection, but I can try to debug this later. |
This comment has been minimized.
This comment has been minimized.
I'd love to have a backtrace.^^ But CI doesn't give us one and indeed I have been unable to reproduce.
So
|
This comment has been minimized.
This comment has been minimized.
|
Regarding the codegen issue, I got it to optimize better by adding some
which has a test saying "there must not be a |
This comment has been minimized.
This comment has been minimized.
|
@RalfJung It looks like the only implementations of |
This comment has been minimized.
This comment has been minimized.
Also all of these have I am a little surprised by the |
This comment has been minimized.
This comment has been minimized.
|
The return value in my code can be misaligned if the slice is length-0. I'd assumed that was OK. |
This comment has been minimized.
This comment has been minimized.
|
Ah, you mean if the inner Now I wonder if |
This comment has been minimized.
This comment has been minimized.
|
Okay, |
RalfJung
force-pushed the
RalfJung:from_raw_parts_align
branch
from
21b76b7
to
6fb97a6
Aug 2, 2018
RalfJung
referenced this pull request
Aug 2, 2018
Merged
Make sure we do not create an unaligned slice #42
This comment has been minimized.
This comment has been minimized.
|
I proposed a fix for |
This comment has been minimized.
This comment has been minimized.
|
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
This comment has been minimized.
This comment has been minimized.
|
llogiq/bytecount#42 has been merged. What has to happen for the Rust test suite to pick it up when testing |
This comment has been minimized.
This comment has been minimized.
|
We need a new ripgrep release that picks up the new version. Then someone needs to upgrade ripgrep. I'll send a ripgrep PR. |
This comment has been minimized.
This comment has been minimized.
Once re-compiling std becomes easier, this will help more, so don't be let down by this, I think adding |
This comment has been minimized.
This comment has been minimized.
|
I updated the ripgrep commit fetched by cargotest. Is anything else needed for updates like this? Also, there still is the problem with the codegen tests. It seems wrong to expect codegen tests to still pass when libstd has debug assertions turned on. What is the best way to ignore some/call codegen tests when |
This comment has been minimized.
This comment has been minimized.
|
We probably want to have a way to disable certain tests when the debug assertions are enabled, by, for example, just adding: // ignore-debug-assertions-onor similar. I don't think compiletest (https://github.com/rust-lang/rust/tree/master/src/tools/compiletest) supports this, but maybe that logic could be added somewhere around here: rust/src/tools/compiletest/src/header.rs Line 600 in c63bb1d |
This comment has been minimized.
This comment has been minimized.
|
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
This comment has been minimized.
This comment has been minimized.
|
@kennytm informs me that all CI runners have debug assertions enabled, except for the ones building the release artifacts with do not run tests. (So we don't test the actual thing we are shipping? oO) So,
|
RalfJung
added some commits
Aug 6, 2018
rust-highfive
assigned
alexcrichton
Aug 18, 2018
This comment has been minimized.
This comment has been minimized.
|
@bors: r+ |
This comment has been minimized.
This comment has been minimized.
|
|
bors
added
S-waiting-on-bors
and removed
S-waiting-on-review
labels
Aug 19, 2018
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Aug 19, 2018
This comment has been minimized.
This comment has been minimized.
|
|
bors
added
S-waiting-on-review
and removed
S-waiting-on-bors
labels
Aug 19, 2018
This comment has been minimized.
This comment has been minimized.
|
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
This comment has been minimized.
This comment has been minimized.
|
I guess this is not 9696 since it is a macOS...
|
bors
added
S-waiting-on-bors
and removed
S-waiting-on-review
labels
Aug 19, 2018
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Aug 19, 2018
This comment has been minimized.
This comment has been minimized.
|
|
bors
merged commit 1001b2b
into
rust-lang:master
Aug 19, 2018
This comment has been minimized.
This comment has been minimized.
|
Tested on commit 8928de7.
|
rust-highfive
added a commit
to rust-lang-nursery/rust-toolstate
that referenced
this pull request
Aug 19, 2018
This comment has been minimized.
This comment has been minimized.
This line: (the same error affects the second edition as well) (We also need to update nomicon to remove |
This comment has been minimized.
This comment has been minimized.
The nomicon is already fixed, but not updated in rustc yet. |
RalfJung
referenced this pull request
Aug 19, 2018
Merged
fix UB in from_raw_parts_mut example #1492
This comment has been minimized.
This comment has been minimized.
|
Submitted rust-lang/book#1492 |
RalfJung commentedAug 2, 2018
•
edited
This does not help nearly as much as I would hope because everybody uses the distributed libstd which is compiled without debug assertions. For this reason, I am not sure if this is even worth it. OTOH, this would have caught the misalignment fixed by #42789 if there had been any tests actually using ZSTs with alignment >1 (we have a CI runner which has debug assertions in libstd enabled), and it seems to currently fail in the rg testsuite. So maybe it is worth it, after all.
I have seen the attribute
#[rustc_inherit_overflow_checks]in some places, does that make it so that the caller's debug status is relevant? Is there a similar attribute fordebug_assert!? That could even subsumerustc_inherit_overflow_checks: Something likerustc_inherit_debug_flagcould affect all places that change the generated code depending on whether we are in debug or release mode. In fact, given that we have to keep around the MIR for generic functions anyway, is there ever a reason not to handle the debug flag that way? I guess currently we apply debug flags likecfgso this is dropped early during the MIR pipeline?EDIT: I learned from @eddyb that because of how
debug_assert!works, this is not realistic. Well, we could still have it for the rustc CI runs and then maybe, eventually, when libstd gets compiled client-side and there is both a debug and a release build... then this will also benefit users.^^