Ralf Jung
b131fc10ae
separate bounds-check from alignment check
2023-10-15 18:13:33 +02:00
Ralf Jung
e24835c6e0
more precise error for 'based on misaligned pointer' case
2023-10-15 18:13:33 +02:00
Ralf Jung
f3f9b795bd
place evaluation: require the original pointer to be aligned if an access happens
2023-10-15 18:13:31 +02:00
Ralf Jung
ea9a24e32e
avoid re-checking the offset while iterating an array/slice
2023-10-15 18:12:46 +02:00
Ralf Jung
b1ebf002c3
don't UB on dangling ptr deref, instead check inbounds on projections
2023-10-15 18:12:46 +02:00
bors
75a5dd05bc
Auto merge of #115524 - RalfJung:misalign, r=wesleywiser
...
const-eval: make misalignment a hard error
It's been a future-incompat error (showing up in cargo's reports) since https://github.com/rust-lang/rust/pull/104616 , Rust 1.68, released in March. That should be long enough.
The question for the lang team is simply -- should we move ahead with this, making const-eval alignment failures a hard error? (It turns out some of them accidentally already were hard errors since #104616 . But not all so this is still a breaking change. Crater found no regression.)
2023-10-14 00:57:09 +00:00
ouz-a
42c39b343d
print normalized ty
2023-10-03 12:17:27 +03:00
Ralf Jung
a993a8bf3f
const-eval: make misalignment a hard error
2023-09-26 15:32:55 +02:00
Ralf Jung
bdbf545f42
interpret: less debug-printing of types
2023-09-20 22:25:42 +02:00
Ralf Jung
5a0a1ff0cd
move ConstValue into mir
...
this way we have mir::ConstValue and ty::ValTree as reasonably parallel
2023-09-19 11:11:02 +02:00
Ralf Jung
06a76ab415
make interpreter type Debug impl independent of Ty debug impl
2023-09-15 09:54:06 +02:00
Ralf Jung
73d8dcb803
miri: catch function calls where the argument is caller-invalid / the return value callee-invalid
2023-09-06 16:36:00 +02:00
Ralf Jung
fa5f13775a
interpret: make MemPlace, Place, Operand types private to the interpreter
2023-09-04 17:53:38 +02:00
Ralf Jung
7cdeff266c
a bit of meta-related cleanup on Projectable
2023-08-30 13:46:55 +02:00
Ralf Jung
a09df43d9f
move marking-locals-live out of push_stack_frame, so it happens with argument passing
...
this entirely avoids even creating unsized locals in Immediate::Uninitialized state
2023-08-30 13:46:54 +02:00
Ralf Jung
bdd5855b8e
interpret: fix projecting into an unsized field of a local
...
new invariant: Place::Local never refers to something unsized
2023-08-30 13:43:34 +02:00
Ben Kimock
ec21d584ee
Record allocation spans inside force_allocation
2023-08-25 11:16:52 -04:00
bors
6d55184d05
Auto merge of #114520 - RalfJung:unsized-valtrees, r=oli-obk
...
simplify handling of valtrees for unsized types
2023-08-08 07:48:01 +00:00
Ralf Jung
997ec63fb1
simplify handling of valtrees for unsized types
2023-08-06 21:25:49 +02:00
Ralf Jung
efd54ccf5a
interpret: use ConstPropNonsense for more const-prop induced issues
2023-08-06 15:20:03 +02:00
Ralf Jung
3345077b42
interpret: add mplace_to_ref helper method
2023-08-04 15:00:57 +02:00
Ralf Jung
7d5886504c
rename deref_operand → deref_pointer and some Miri helper functions
2023-08-01 13:40:29 +02:00
Ralf Jung
da3f0d0eb7
make MPlaceTy non-Copy
2023-07-25 22:35:07 +02:00
Ralf Jung
77ff1b83cd
interpret: make read functions generic over operand type
2023-07-25 22:33:59 +02:00
Ralf Jung
00fb45dccd
interpret: make write functions generic over the place type
2023-07-25 22:33:58 +02:00
Ralf Jung
d127600511
add some sanity checks in write_immediate_no_validate
2023-07-25 14:30:58 +02:00
Ralf Jung
a2bcafa500
interpret: refactor projection code to work on a common trait, and use that for visitors
2023-07-25 14:30:58 +02:00
Ralf Jung
a593de4fab
interpret: support projecting into Place::Local without force_allocation
2023-07-24 15:35:47 +02:00
Mark Rousskov
cc907f80b9
Re-format let-else per rustfmt update
2023-07-12 21:49:27 -04:00
Ralf Jung
e7c6db7d44
fix handling of alignment for dyn-sized places
2023-07-11 21:59:01 +02:00
Ralf Jung
dd453a6a99
miri: protect Move() function arguments during the call
2023-07-11 21:59:01 +02:00
Ralf Jung
7a83ef82da
miri: check that assignments do not self-overlap
2023-07-07 16:54:44 +02:00
Boxy
12138b8e5e
Move TyCtxt::mk_x to Ty::new_x where applicable
2023-07-05 20:27:07 +01:00
Maybe Waffle
e496fbec92
Split {Idx, IndexVec, IndexSlice} into their own modules
2023-04-24 13:53:35 +00:00
Scott McMurray
b5b6def021
Use FieldIdx in various things related to aggregates
...
Shrank `AggregateKind` by 8 bytes on x64, since the active field of a union is tracked as an `Option<FieldIdx>` instead of `Option<usize>`.
2023-04-01 20:32:50 -07:00
Scott McMurray
0439d13176
Refactor: VariantIdx::from_u32(0) -> FIRST_VARIANT
...
Since structs are always `VariantIdx(0)`, there's a bunch of files where the only reason they had `VariantIdx` or `vec::Idx` imported at all was to get the first variant.
So this uses a constant for that, and adds some doc-comments to `VariantIdx` while I'm there, since it doesn't have any today.
2023-03-25 18:58:25 -07:00
Oli Scherer
83dec62b26
Add a layout argument to enforce_validity.
...
This is in preparation of checking the validity only of certain types.
2023-03-21 08:52:31 +00:00
Matthias Krüger
f75f440bbf
Rollup merge of #108022 - CraftSpider:align-bytes, r=oli-obk
...
Support allocations with non-Box<[u8]> bytes
This is prep work for allowing miri to support passing pointers to C code, which will require `Allocation`s to be correctly aligned. Currently, it just makes `Allocation` generic and plumbs the necessary changes through the right places.
The follow-up to this will be adding a type in the miri interpreter which correctly aligns the bytes, using that for the Miri engine, then allowing Miri to pass pointers into these allocations to C calls.
Based off of #100467 , credit to ```@emarteca``` for the code
2023-03-02 23:05:27 +01:00
Rune Tynan
936b567d2e
Minimal changes to make miri work
2023-02-20 13:50:20 -05:00
Rune Tynan
6f407d67b8
Allow non-Box allocations in preparation for aligned const allocations for miri. Credit to emarteca for the code.
2023-02-20 13:47:09 -05:00
Ralf Jung
b2f58146b9
basic dyn* support for Miri
2023-02-20 15:08:05 +01:00
Oli Scherer
38b7cdf393
Use target instead of machine for mir interpreter integer handling.
...
The naming of `machine` only makes sense from a mir interpreter internals perspective, but outside users talk about the `target` platform
2023-02-15 08:56:18 +00:00
Ralf Jung
91d25168cd
interpret: rename Pointer::from_addr → from_addr_invalid
2023-02-14 14:55:50 +01:00
Matthias Krüger
d044c1bde4
Rollup merge of #107756 - RalfJung:miri-out-of-addresses, r=oli-obk
...
miri: fix ICE when running out of address space
Fixes https://github.com/rust-lang/miri/issues/2769
r? `@oli-obk`
I didn't add a test since that requires https://github.com/oli-obk/ui_test/issues/38 (host must be 64bit and target 32bit). Also the test takes ~30s, so I am not sure if we want to have it in the test suite?
2023-02-07 17:57:18 +01:00
Ralf Jung
2900ba15b3
miri: fix ICE when running out of address space
2023-02-07 13:26:31 +01:00
Ralf Jung
e1926b2110
interpret: move discriminant reading and writing to separate file
2023-02-06 17:10:26 +01:00
Camille GILLOT
473d0c5510
Introduce write_aggregate.
2023-02-02 23:26:34 +00:00
Camille GILLOT
feccf469fb
Interpret aggregates.
2023-02-02 23:09:51 +00:00
Maybe Waffle
6a28fb42a8
Remove double spaces after dots in comments
2023-01-17 08:09:33 +00:00
Matthias Krüger
0aa4cde747
avoid .into() conversion to identical types
2022-12-18 16:20:32 +01:00