Show the offset, length and memory of uninit read errors#142673
Show the offset, length and memory of uninit read errors#142673bors merged 2 commits intorust-lang:masterfrom
Conversation
| throw_ub!(InvalidUninitBytes(None)); | ||
| throw_ub!(InvalidUninitBytes(match op.to_op(self)?.as_mplace_or_imm() { | ||
| Left(mplace) => mplace.ptr().provenance.and_then(|prov| { | ||
| let start = mplace.ptr().into_parts().1; | ||
| let size = op.layout().size; | ||
| let range = alloc_range(start, size); | ||
| Some((prov.get_alloc_id()?, BadBytesAccess { access: range, bad: range })) | ||
| }), | ||
| Right(_) => None, | ||
| })) |
There was a problem hiding this comment.
This one doesn't show up in diagnostics, but it seemed good to change it, too
There was a problem hiding this comment.
Why doesn't it show up in diagnostics? Aren't all the miri output diffs caused by exactly this?
There was a problem hiding this comment.
Ah no, that diff is probably caused by the read_scalar change.
If this logic here can't be tested, I'd rather remove it, given that it is currently wrong due to how it uses into_parts.
There was a problem hiding this comment.
This is read_immediate, #142839 does nothing there...?
There was a problem hiding this comment.
oh right, I mixed up things.
hmm. yea I think I just tried this one because I thought it should be hit somewhere. So I'll turn it into a span_bug
There was a problem hiding this comment.
ok, digging into this got more interesting. I added two more commits. TLDR: we only ever use Immediate::Uninit for zsts or for uninit locals. But reading uninit locals only happens by converting them to Operand, which handles uninit immediates if processed by erroring.
There was a problem hiding this comment.
That's kind of an accidental invariant though, I think... is it worth relying on?
There was a problem hiding this comment.
It allows some simplifications. lmk what you think about the latest commits and I can either restore the previous zst/uninit design, or we keep it and revisit if we notice there's something better to do with it (or matthias manages to fuzz us examples of how that code is actually reachable for non-zsts)
There was a problem hiding this comment.
ok, looks like mir opts use uninit a lot more, so I backed out that commit
This comment has been minimized.
This comment has been minimized.
|
grml. I haven't been able to run miri's dep tests in-tree in forever. Always sth about libc not found. Will try to bless the others and hope none of these need blessing |
|
The Miri subtree was changed cc @rust-lang/miri |
This comment has been minimized.
This comment has been minimized.
ff2e26b to
0120c8e
Compare
| throw_ub!(InvalidUninitBytes(None)); | ||
| throw_ub!(InvalidUninitBytes(match op.to_op(self)?.as_mplace_or_imm() { | ||
| Left(mplace) => mplace.ptr().provenance.and_then(|prov| { | ||
| let start = mplace.ptr().into_parts().1; | ||
| let size = op.layout().size; | ||
| let range = alloc_range(start, size); | ||
| Some((prov.get_alloc_id()?, BadBytesAccess { access: range, bad: range })) | ||
| }), | ||
| Right(_) => None, | ||
| })) |
There was a problem hiding this comment.
Why doesn't it show up in diagnostics? Aren't all the miri output diffs caused by exactly this?
| throw_ub!(InvalidUninitBytes(None)); | ||
| throw_ub!(InvalidUninitBytes(match op.to_op(self)?.as_mplace_or_imm() { | ||
| Left(mplace) => mplace.ptr().provenance.and_then(|prov| { | ||
| let start = mplace.ptr().into_parts().1; |
There was a problem hiding this comment.
This is not correct -- depending on which type of provenance this is, start will be either relative to the allocation, or absolute. into_parts has a doc comment warning about this. :) Maybe we should rename it into_raw_parts or so to make it more clear that this API is somewhat dicey.
|
☔ The latest upstream changes (presumably #143091) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
3abcbd3 to
67c2e92
Compare
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
☔ The latest upstream changes (presumably #142839) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@rustbot ready |
src/tools/miri/tests/fail-dep/concurrency/libc_pthread_cond_double_destroy.stderr
Outdated
Show resolved
Hide resolved
|
(CI doesn't run as there is still a conflict) |
|
yea was running locally to see if there were any issues after the rebase |
RalfJung
left a comment
There was a problem hiding this comment.
r=me with the last nit resolved and when CI is green.
| // | ||
| // See <https://github.com/rust-lang/miri/issues/4237>. | ||
|
|
||
| //@ stderr-per-bitwidth |
There was a problem hiding this comment.
I'd prefer normalizing the output over having two stderr files.
|
@bors r=RalfJung |
Show the offset, length and memory of uninit read errors r? `@RalfJung` I want to improve memory dumps in general. Not sure yet how to do so best within rust diagnostics, but in a perfect world I could generate a dummy in-memory file (that contains the rendered memory dump) that we then can then provide regular rustc `Span`s to. So we'd basically report normal diagnostics for them with squiggly lines and everything.
Rollup of 9 pull requests Successful merges: - #138554 (Distinguish delim kind to decide whether to emit unexpected closing delimiter) - #142673 (Show the offset, length and memory of uninit read errors) - #142693 (More robustly deal with relaxed bounds and improve their diagnostics) - #143382 (stabilize `const_slice_reverse`) - #143928 (opt-dist: make llvm builds optional) - #143961 (Correct which exploit mitigations are enabled by default) - #144050 (Fix encoding of link_section and no_mangle cross crate) - #144059 (Refactor `CrateLoader` into the `CStore`) - #144123 (Generalize `unsize` and `unsize_into` destinations) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 9 pull requests Successful merges: - #138554 (Distinguish delim kind to decide whether to emit unexpected closing delimiter) - #142673 (Show the offset, length and memory of uninit read errors) - #142693 (More robustly deal with relaxed bounds and improve their diagnostics) - #143382 (stabilize `const_slice_reverse`) - #143928 (opt-dist: make llvm builds optional) - #143961 (Correct which exploit mitigations are enabled by default) - #144050 (Fix encoding of link_section and no_mangle cross crate) - #144059 (Refactor `CrateLoader` into the `CStore`) - #144123 (Generalize `unsize` and `unsize_into` destinations) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 9 pull requests Successful merges: - #138554 (Distinguish delim kind to decide whether to emit unexpected closing delimiter) - #142673 (Show the offset, length and memory of uninit read errors) - #142693 (More robustly deal with relaxed bounds and improve their diagnostics) - #143382 (stabilize `const_slice_reverse`) - #143928 (opt-dist: make llvm builds optional) - #143961 (Correct which exploit mitigations are enabled by default) - #144050 (Fix encoding of link_section and no_mangle cross crate) - #144059 (Refactor `CrateLoader` into the `CStore`) - #144123 (Generalize `unsize` and `unsize_into` destinations) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #142673 - oli-obk:uninit-read-mem, r=RalfJung Show the offset, length and memory of uninit read errors r? ``@RalfJung`` I want to improve memory dumps in general. Not sure yet how to do so best within rust diagnostics, but in a perfect world I could generate a dummy in-memory file (that contains the rendered memory dump) that we then can then provide regular rustc `Span`s to. So we'd basically report normal diagnostics for them with squiggly lines and everything.
Rollup of 9 pull requests Successful merges: - rust-lang/rust#138554 (Distinguish delim kind to decide whether to emit unexpected closing delimiter) - rust-lang/rust#142673 (Show the offset, length and memory of uninit read errors) - rust-lang/rust#142693 (More robustly deal with relaxed bounds and improve their diagnostics) - rust-lang/rust#143382 (stabilize `const_slice_reverse`) - rust-lang/rust#143928 (opt-dist: make llvm builds optional) - rust-lang/rust#143961 (Correct which exploit mitigations are enabled by default) - rust-lang/rust#144050 (Fix encoding of link_section and no_mangle cross crate) - rust-lang/rust#144059 (Refactor `CrateLoader` into the `CStore`) - rust-lang/rust#144123 (Generalize `unsize` and `unsize_into` destinations) r? `@ghost` `@rustbot` modify labels: rollup
Show the offset, length and memory of uninit read errors r? ``@RalfJung`` I want to improve memory dumps in general. Not sure yet how to do so best within rust diagnostics, but in a perfect world I could generate a dummy in-memory file (that contains the rendered memory dump) that we then can then provide regular rustc `Span`s to. So we'd basically report normal diagnostics for them with squiggly lines and everything.
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#138554 (Distinguish delim kind to decide whether to emit unexpected closing delimiter) - rust-lang#142673 (Show the offset, length and memory of uninit read errors) - rust-lang#142693 (More robustly deal with relaxed bounds and improve their diagnostics) - rust-lang#143382 (stabilize `const_slice_reverse`) - rust-lang#143928 (opt-dist: make llvm builds optional) - rust-lang#143961 (Correct which exploit mitigations are enabled by default) - rust-lang#144050 (Fix encoding of link_section and no_mangle cross crate) - rust-lang#144059 (Refactor `CrateLoader` into the `CStore`) - rust-lang#144123 (Generalize `unsize` and `unsize_into` destinations) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 9 pull requests Successful merges: - rust-lang/rust#138554 (Distinguish delim kind to decide whether to emit unexpected closing delimiter) - rust-lang/rust#142673 (Show the offset, length and memory of uninit read errors) - rust-lang/rust#142693 (More robustly deal with relaxed bounds and improve their diagnostics) - rust-lang/rust#143382 (stabilize `const_slice_reverse`) - rust-lang/rust#143928 (opt-dist: make llvm builds optional) - rust-lang/rust#143961 (Correct which exploit mitigations are enabled by default) - rust-lang/rust#144050 (Fix encoding of link_section and no_mangle cross crate) - rust-lang/rust#144059 (Refactor `CrateLoader` into the `CStore`) - rust-lang/rust#144123 (Generalize `unsize` and `unsize_into` destinations) r? `@ghost` `@rustbot` modify labels: rollup
r? @RalfJung
I want to improve memory dumps in general. Not sure yet how to do so best within rust diagnostics, but in a perfect world I could generate a dummy in-memory file (that contains the rendered memory dump) that we then can then provide regular rustc
Spans to. So we'd basically report normal diagnostics for them with squiggly lines and everything.