Commit Graph

122 Commits

Author SHA1 Message Date
Oliver Scherer 769ee79a69 Fallout 2018-11-08 14:52:02 +01:00
Ralf Jung 154835e5e7 only count deref_operand as actual deref, but not all ref-to-place conversions 2018-11-07 16:54:31 +01:00
Ralf Jung b42b9b34d5 pretty-print scalar range that only has an upper bound 2018-11-07 13:58:43 +01:00
Ralf Jung 9dba743a6a do not print wrapping ranges like normal ranges in diagnostics 2018-11-07 13:46:49 +01:00
Ralf Jung 873041009d make ValueVisitor mut-polymorphic 2018-11-05 10:15:25 +01:00
Ralf Jung 91cad39614 visit_aggregate with an iterator; fix some comment typos 2018-11-05 09:59:05 +01:00
Ralf Jung 996a42557e the visitor can already load the value for visit_primitive 2018-11-05 09:40:05 +01:00
Ralf Jung b096f0846e finally this actually looks like a visitor 2018-11-05 09:37:13 +01:00
Ralf Jung 98295e9eb2 use more traditional walk_array/visit_array instead of the handle_array hook 2018-11-05 09:29:39 +01:00
Ralf Jung fa01e04fbb fix validation error on non-integer enum discriminants 2018-11-05 09:17:48 +01:00
Ralf Jung 6d24b37a70 let the Value handle enum projections, so the visitor does not have to care 2018-11-05 09:17:48 +01:00
Ralf Jung 33770abbe2 add visit() hook to the trait 2018-11-05 09:17:48 +01:00
Ralf Jung fdc3a3ed0c fix for pre-NLL rustc 2018-11-05 09:17:48 +01:00
Ralf Jung 7d7bd9b6c2 reduce the amount of traversal/projection code that the visitor has to implement itself 2018-11-05 09:17:48 +01:00
Ralf Jung 5b5e076b47 generalize the traversal part of validation to a ValueVisitor 2018-11-05 09:15:46 +01:00
Oliver Scherer e8a22b692a Rename `Value` to `Immediate` for miri 2018-11-02 16:56:59 +01:00
Matthias Krüger f6b8876d45 use String::from() instead of format!() macro to construct Strings. 2018-10-31 00:10:10 +01:00
Oliver S̶c̶h̶n̶e̶i̶d̶e̶r Scherer 3e9d7e8aa8
Add a comment explaining the two checks 2018-10-29 21:31:22 +01:00
Oliver Scherer 3ad154f484 Fix wrong validation clasisfication of `Option<&T>::Some` values 2018-10-29 15:22:47 +01:00
Ralf Jung f5e8830278 validity in non-const mode relies on ref_to_mplace checking bounds; (de)reference hooks work on places 2018-10-28 11:21:41 +01:00
Ralf Jung 6b980462c6 validity: assert that unions are non-empty 2018-10-26 11:08:24 +02:00
Matthias Krüger 4972beaf65 fix typos in various places 2018-10-23 15:56:25 +02:00
bors 66910ba686 Auto merge of #55125 - RalfJung:stacked-borrows, r=oli-obk
miri engine: Hooks for basic stacked borrows

r? @oli-obk
2018-10-21 09:32:25 +00:00
Oliver Scherer ee81739dc1 Deprecate the `FxHashMap()` and `FxHashSet()` constructor function hack 2018-10-19 14:34:44 +02:00
Ralf Jung 290db47ad6 comment on keeping validity in sync 2018-10-18 12:08:22 +02:00
Ralf Jung 06a4911ce1 run-time validation: accept undef in int arrays, as we do for ints 2018-10-13 09:09:03 +02:00
Ralf Jung b2ddd27c2e address nits 2018-10-13 09:09:03 +02:00
Ralf Jung dc4b2771f8 validation: accept pointers in integer arrays 2018-10-13 09:09:03 +02:00
Ralf Jung c96eb706f0 Fix and test upvar name printing for validity 2018-10-13 09:09:03 +02:00
Ralf Jung 3272c9845c foreign types: use size and align from layout 2018-10-13 09:09:03 +02:00
Ralf Jung d0c585c525 seems like for generators we cannot access the freevars 2018-10-13 09:09:03 +02:00
Ralf Jung 93f53e5113 size_and_align_of can return no result for extern types 2018-10-13 09:09:03 +02:00
Ralf Jung 5b75ec0a91 fix validation around transmuting copy_op 2018-10-13 09:09:02 +02:00
Ralf Jung 397283dbc3 rename extra -> meta in place 2018-10-10 09:58:17 +02:00
Ralf Jung 4e9f9329e3 miri engine: basic support for pointer provenance tracking 2018-10-10 09:50:06 +02:00
Ralf Jung fe96f8235c validity: check dynamic size, not static
also less verbose logging
2018-10-09 13:08:00 +02:00
Ralf Jung 976880aa84 dont fail when validating non-local closures 2018-10-09 13:08:00 +02:00
Ralf Jung 6899af82fd box is also a primitive type 2018-10-09 13:08:00 +02:00
Ralf Jung fcf6b5c79b add fixme for potential perf optimization 2018-10-09 13:08:00 +02:00
Ralf Jung e09e3c898c fix nits and handling of extern static 2018-10-09 13:08:00 +02:00
Ralf Jung 322017b2bc unify handling of thin and fat pointers by moving primitive type handling out of aggregate handling
Also, make enum variant handling a bit nicer
2018-10-09 13:08:00 +02:00
Ralf Jung 22c1a0acc8 For now, accept all data for integer types when not in const mode
We'll try ruling out undef later
2018-10-09 13:08:00 +02:00
Ralf Jung 9bb4bcd770 tidy up 2018-10-09 13:08:00 +02:00
Ralf Jung 654d9ff618 do not look at refs to external statics at all 2018-10-09 13:08:00 +02:00
Ralf Jung d2b9b1de05 add machine option to validate things on every copy 2018-10-09 13:08:00 +02:00
Ralf Jung 69a320f40d also validate everything that has a Scalar layout, to catch NonNull 2018-10-09 13:08:00 +02:00
Ralf Jung 0a2fae6cb7 fix validating arrays of ZSTs
Fixes #54751
2018-10-09 13:08:00 +02:00
Ralf Jung f65d3b5491 switch validation of scalars to be type-driven
This does not actually regress anything.  It would regress NonNull, but we
didn't handle that correctly previously either.
2018-10-09 13:08:00 +02:00
Ralf Jung ff5a245f52 check that entire ref is in-bounds before recursing; add macro for validation msgs on error 2018-10-09 13:08:00 +02:00
Ralf Jung bf5e6ebdd3 miri validity: make recursive ref checking optional 2018-10-09 13:08:00 +02:00
Ralf Jung d62aa3e085 move ScalarMaybeUndef into the miri engine 2018-09-30 13:09:26 +02:00
Ralf Jung 169f7911e9 move CTFE engine snapshot state out of miri engine into CTFE machine instance 2018-09-20 10:12:21 +02:00
Gabriel Majeri 82cde902c5 Optimize miri checking of integer array/slices
Instead of checking every element, we can check the whole memory
range at once.
2018-09-08 07:13:19 +03:00
thedarkula de0cd23e48 Added pointer checking to sanity checks 2018-08-31 16:25:01 +01:00
Ralf Jung cdeef61425 move some Scalar helpers from miri here, and use them where appropriate 2018-08-29 08:44:37 +02:00
Ralf Jung f96208ca5b address nits 2018-08-28 19:57:05 +02:00
Ralf Jung 5b737dbbf4 get rid of *most* of the fn call hack by honoring mir.spread_arg 2018-08-27 18:12:49 +02:00
Ralf Jung c38cc896dc fix len() on non-array but array-layout types (e.g. SIMD) 2018-08-27 18:12:49 +02:00
Ralf Jung c898e1911d fix handling of unsized types in validation; validate str to be UTF-8 2018-08-27 18:12:49 +02:00
Ralf Jung 89cfd08b47 validate enum discriminant whenever it is read 2018-08-27 18:12:49 +02:00
Ralf Jung 035c69f658 switch validation to use operand, not mplace
this means we can get rid of the public allocate_op, and make OpTy only
constructible in librustc_mir
2018-08-27 18:12:49 +02:00
Bernardo Meurer 22d3f66945
Fixup long code lines 2018-08-23 08:55:42 -07:00
Bernardo Meurer 35f25bfef3
Reflow and fixup comments 2018-08-23 08:54:23 -07:00
Bernardo Meurer 22beeb4cab
Add license header to CTFE/MIRI 2018-08-23 08:51:44 -07:00
varkor 71722b9cef Fix rebase issues 2018-08-22 16:15:56 +01:00
Ralf Jung 4fec615ebf fix error reporting in validation 2018-08-22 13:08:40 +02:00
Ralf Jung 899bc14cc0 fix validating fat pointers to user-defined unsized types 2018-08-22 13:08:40 +02:00
Ralf Jung 14dc780d89 fix a comment in validity 2018-08-22 13:08:40 +02:00
Ralf Jung c3d392f5f5 fix validating fat raw pointers 2018-08-22 13:08:39 +02:00
Ralf Jung 49999e9b1d optimize sanity check path printing
During the sanity check, we keep track of the path we are below in a `Vec`.  We
avoid cloning that `Vec` unless we hit a pointer indirection.  The `String`
representation is only computed when validation actually fails.
2018-08-22 13:08:39 +02:00
Ralf Jung 956b51f79a optimize validation iterating over the elements of an array
This is still roughly 45ns slower than the old state, because it now works with
an MPlaceTy and uses the appropriate abstractions, instead of working with a
ptr-align pair directly.
2018-08-22 13:08:39 +02:00
Ralf Jung 5099933614 move validation to its own file 2018-08-22 13:08:38 +02:00