-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CTFE engine refactor #53424
Merged
Merged
CTFE engine refactor #53424
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
7d4f5f7
Move some value-and-memory related things out of eval_context
RalfJung ad2de8b
miri/CTFE refactor
RalfJung 7483ea8
generalize truncate and sign_extend to take a Size
RalfJung 689c711
remove cur_frame from memory (validation is gone, new validation will…
RalfJung 0807ad1
fix union field access and DST computations and dumping of places
RalfJung e860ab2
Tweak logging
RalfJung 09b15e9
fix dropping with vtables
RalfJung 1e137a7
fix drop typing; use same machinery for validating (sanity checking) …
RalfJung e314a4e
fix accessing unsized fields
RalfJung 61e7ba1
fix dynamically determining size and alignment
RalfJung 23d86b0
try_read_value_from_ptr -> try_read_value_from_mplace
RalfJung ad009ae
fix using copy_op to transmute
RalfJung 730098b
avoid allocating for ZST
RalfJung b1df2ae
fix computing layout when calling virtual fn
RalfJung aa760a5
finally remove all traces of signs from memory
RalfJung f2aeb5b
fix operator handling when using 128bit intrinsics
RalfJung 5099933
move validation to its own file
RalfJung ad8deba
fix formatting nits
RalfJung 6f5cf12
test for detecting bad data inside trait objects / slices
RalfJung 956b51f
optimize validation iterating over the elements of an array
RalfJung 0b8c691
fix UI tests
RalfJung e3b4f8e
better error message when using NULL in to_ptr
RalfJung 42a1239
avoid some redundant alignment checks
RalfJung 49999e9
optimize sanity check path printing
RalfJung c3d392f
fix validating fat raw pointers
RalfJung 8ad4047
optimize creating a stack frame
RalfJung 54c81ac
in a Use statement, exploit the fact that type and hence layout are t…
RalfJung 128c634
also avoid recomputing the layout for unary and binary ops, where pos…
RalfJung f3e7efc
fix layout sanity check
RalfJung 14dc780
fix a comment in validity
RalfJung 899bc14
fix validating fat pointers to user-defined unsized types
RalfJung 4fec615
fix error reporting in validation
RalfJung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test for detecting bad data inside trait objects / slices
- Loading branch information
commit 6f5cf1289431ceb32ec652b7c26962e2f3048263
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,75 @@ | ||
error[E0080]: this constant likely exhibits undefined behavior | ||
--> $DIR/union-ub-fat-ptr.rs:70:1 | ||
--> $DIR/union-ub-fat-ptr.rs:76:1 | ||
| | ||
LL | const B: &str = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.str}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access at offset N, outside bounds of allocation N which has size N | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior | ||
|
||
error[E0080]: this constant likely exhibits undefined behavior | ||
--> $DIR/union-ub-fat-ptr.rs:73:1 | ||
--> $DIR/union-ub-fat-ptr.rs:79:1 | ||
| | ||
LL | const C: &str = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.str}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered length is not a valid integer | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior | ||
|
||
error[E0080]: this constant likely exhibits undefined behavior | ||
--> $DIR/union-ub-fat-ptr.rs:79:1 | ||
--> $DIR/union-ub-fat-ptr.rs:85:1 | ||
| | ||
LL | const B2: &[u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.slice}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access at offset N, outside bounds of allocation N which has size N | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior | ||
|
||
error[E0080]: this constant likely exhibits undefined behavior | ||
--> $DIR/union-ub-fat-ptr.rs:82:1 | ||
--> $DIR/union-ub-fat-ptr.rs:88:1 | ||
| | ||
LL | const C2: &[u8] = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.slice}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered length is not a valid integer | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior | ||
|
||
error[E0080]: this constant likely exhibits undefined behavior | ||
--> $DIR/union-ub-fat-ptr.rs:86:1 | ||
--> $DIR/union-ub-fat-ptr.rs:92:1 | ||
| | ||
LL | const D: &Trait = unsafe { DynTransmute { repr: DynRepr { ptr: &92, vtable: &3 } }.rust}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tried to access memory with alignment N, but alignment N is required | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior | ||
|
||
error[E0080]: this constant likely exhibits undefined behavior | ||
--> $DIR/union-ub-fat-ptr.rs:89:1 | ||
--> $DIR/union-ub-fat-ptr.rs:95:1 | ||
| | ||
LL | const E: &Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.rust}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ a memory access tried to interpret some bytes as a pointer | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior | ||
|
||
error[E0080]: this constant likely exhibits undefined behavior | ||
--> $DIR/union-ub-fat-ptr.rs:92:1 | ||
--> $DIR/union-ub-fat-ptr.rs:98:1 | ||
| | ||
LL | const F: &Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 3 } }.rust}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered vtable address is not a pointer | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior | ||
|
||
error: aborting due to 7 previous errors | ||
error[E0080]: this constant likely exhibits undefined behavior | ||
--> $DIR/union-ub-fat-ptr.rs:102:1 | ||
| | ||
LL | const G: &Trait = &unsafe { BoolTransmute { val: 3 }.bl }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at .data_ptr, but expected something in the range 0..=1 | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior | ||
|
||
error[E0080]: this constant likely exhibits undefined behavior | ||
--> $DIR/union-ub-fat-ptr.rs:106:1 | ||
| | ||
LL | const H: &[bool] = &[unsafe { BoolTransmute { val: 3 }.bl }]; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at .data_ptr[0], but expected something in the range 0..=1 | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior | ||
|
||
error: aborting due to 9 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0080`. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you also add a test where a trait object has the correct vtable and pointer but the object is wrong? So create the object unsafely with brokenness and then downcast
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added these:
Does that look like it is testing the right thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You forgot to push, but assuming that
bool: Trait
it shouldThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I just waited for
--bless
to finish before pushing. ;)