Commit Graph

971 Commits

Author SHA1 Message Date
Oliver Schneider
4cfa7c5d12
Prep miri repository for rustc merger 2017-07-21 11:30:56 +02:00
Oliver Schneider
b4e300d577 Merge pull request #266 from RalfJung/align
Always test alignment in memory.rs
2017-07-21 09:46:50 +02:00
Ralf Jung
14cb85809b always test alignment in memory.rs 2017-07-20 13:24:06 -07:00
Oliver Schneider
f2d0101065
Also test optimized MIR 2017-07-20 20:25:43 +02:00
Oliver Schneider
9710ff481e Merge pull request #264 from oli-obk/paths
Reduce the usage of global paths
2017-07-20 20:00:19 +02:00
Oliver Schneider
9b526d1c85 Reduce the usage of global paths 2017-07-20 16:40:57 +02:00
Eduard-Mihai Burtescu
e79bb42ab3 Merge pull request #262 from RalfJung/never
remove ad-hoc 'never' type check in read_lvalue
2017-07-20 15:13:21 +03:00
Oliver Schneider
f02d9e63fd Merge pull request #259 from RalfJung/ref-validate
No longer check aligment and non-NULLness on `&`
2017-07-20 07:09:52 +02:00
Ralf Jung
3b19c83c67 remove ad-hoc 'never' type check in read_lvalue 2017-07-19 20:32:51 -07:00
Ralf Jung
ede055c2be fix checking alignment of pointer loads 2017-07-19 20:24:09 -07:00
Ralf Jung
f9818bf818 fix a warning 2017-07-19 13:31:21 -07:00
Ralf Jung
2424953055 Don't pretend that casts to bool are a thing 2017-07-19 11:35:06 -07:00
Ralf Jung
72664e42aa No longer check aligment and non-NULLness on &
This breaks creating unaligned raw pointers via `&packed.field as *const _`, which needs to be legal.
Also it doesn't seem like LLVM still relies on this, see
* https://github.com/solson/miri/issues/244#issuecomment-315563640
* https://internals.rust-lang.org/t/rules-for-alignment-and-non-nullness-of-references/5430/16

We probably want to handle this invariant like the others that validation is concerned with, and only
check it on function boundaries for now.
2017-07-19 11:28:35 -07:00
Oliver Schneider
27c64479cd Merge pull request #257 from oli-obk/cleanups
Export types and functions needed by priroda
2017-07-19 11:40:43 +02:00
Oliver Schneider
d9d792ba03 Export types and functions needed by priroda 2017-07-19 11:06:07 +02:00
Oliver Schneider
2d5c4196f1 Merge pull request #254 from RalfJung/dangling
Remove reundant dangling checks in {r,d}eallocate
2017-07-18 23:34:09 +02:00
Ralf Jung
9bccfd388c use libstd methods for floating-point <-> bytes conversion 2017-07-18 13:56:01 -07:00
Ralf Jung
ff9192e346 remove reundant dangling checks in {r,d}eallocate 2017-07-18 13:50:54 -07:00
Oliver Schneider
5328c5d1b0 Merge pull request #245 from oli-obk/funky_allocs
Ensure that it is not possible to explicitly free stack memory
2017-07-18 14:09:15 +02:00
Ralf Jung
2312ac8db6 lvalue: refactoring to permit applying a mir projection to a miri lvalue 2017-07-14 09:06:52 -07:00
Oliver Schneider
45ab975610 Add a comment explaining the static "local" during deallocate_local 2017-07-14 17:46:28 +02:00
Oliver Schneider
2e562a4d64
Fix static mutation tests 2017-07-14 17:39:19 +02:00
Oliver Schneider
eb01c3fdd2
Use enum instead of boolean 2017-07-14 17:39:19 +02:00
Oliver Schneider
70a914cd34
Clarify documentation 2017-07-14 17:36:06 +02:00
Oliver Schneider
192da8819f
Ensure that it is not possible to explicitly free stack memory 2017-07-14 17:36:06 +02:00
Oliver Schneider
56d4de303f Merge pull request #247 from RalfJung/packed
Re-do packed memory accesses
2017-07-14 08:30:30 +02:00
Ralf Jung
da5538f0b2 use closures to ensure proper bracketing of unaligned accesses 2017-07-13 10:29:11 -07:00
Ralf Jung
d02e7f0da8 simplify 2017-07-13 09:10:50 -07:00
Ralf Jung
62334acd66 show alignedness of ByRefs; allow converting unaligned ByRef to ptr 2017-07-13 09:09:45 -07:00
Ralf Jung
6fb6a1c4d0 make all Value::into_* methods handle alignment the same way 2017-07-13 09:06:27 -07:00
Ralf Jung
6c9fdc7922 expand comment 2017-07-13 08:40:05 -07:00
Oliver Schneider
f8757aa092 Reuse the const_eval method for syscall name resolution 2017-07-13 16:49:55 +02:00
Oliver Schneider
f78d6a0d97
Don't use magic numbers for synconf names
instead read them from the `libc` crate if available.

fixes #216
2017-07-13 16:31:14 +02:00
Oliver Schneider
fdef27acf5
Copy path_to_def from clippy 2017-07-13 16:31:14 +02:00
Ralf Jung
81307d7299 fix "unaligned" transmute 2017-07-12 23:50:57 -07:00
Ralf Jung
287b6be5ca track alignment also for ByRef values 2017-07-12 21:06:57 -07:00
Ralf Jung
1fe310c8ba Memory::read_ptr has to check for relocations on the edges 2017-07-12 19:30:37 -07:00
Ralf Jung
454fc854ab Rename value accessors to "into_*" so the three of them are better aligned 2017-07-12 17:52:57 -07:00
Ralf Jung
c149c3fc6a Re-do packed memory accesses
We now track in the lvalue whether what we computed is expected to be aligend or not, and then set some state in the memory system accordingly to make it (not) do alignment checks
2017-07-12 17:46:56 -07:00
Oliver Schneider
4ce8be9538 Produce ConstInt from a def_id for rustc 2017-07-12 10:38:54 +02:00
Ralf Jung
eafe659ee0 hooking mmap is no longer needed 2017-07-11 17:24:15 -07:00
Oliver Schneider
eba199a437 Document the reason for Pointer's existence 2017-07-11 12:50:03 +02:00
Oliver Schneider
0dd6ef8301 Simplify with_extra 2017-07-11 12:39:12 +02:00
Oliver Schneider
d0d1d2d5e8
Remove *offset* methods from PrimVal onto Pointer 2017-07-11 12:28:11 +02:00
Oliver Schneider
03f0a88002
Use a wrapper type to differentiate between PrimVal and pointers 2017-07-11 12:28:11 +02:00
Oliver Schneider
a8b957a0f8
Add a dedicated write_null method 2017-07-11 10:32:01 +02:00
Oliver Schneider
2d52054fb2
Rename Pointer to MemoryPointer 2017-07-11 10:32:01 +02:00
Ralf Jung
1cbf5e8962 leave notes regarding possible alignment checks 2017-07-10 18:09:46 -07:00
Ralf Jung
d2cf3d76b9 update for allocator API 2017-07-10 16:15:58 -07:00
Ralf Jung
3c0a6d6922 simplify reallocate 2017-07-10 13:34:54 -07:00
Oliver Schneider
b8bd42e8d4 Merge pull request #234 from RalfJung/reallocate
Make Reallocate & Deallocate less permissive
2017-07-05 19:54:54 +02:00
Ralf Jung
4165051073 refine comment explaining the order of checks on deallocate 2017-07-05 10:26:15 -07:00
Oliver Schneider
9a04be974c Merge pull request #232 from oli-obk/master
Only check pointers when dereferencing
2017-07-04 09:50:54 +02:00
Oliver Schneider
10ec543b9e Merge pull request #235 from RalfJung/intrinsics
Implement some missing intrinsics
2017-07-04 08:38:22 +02:00
Ralf Jung
30f92f8a27 catch overflows that are hidden by first casting the RHS to u32 2017-07-03 20:50:19 -07:00
Ralf Jung
ffd482e2f5 check the assumptions made by the unchecked_ and copy_nonoverlapping intrinsics 2017-07-03 20:37:38 -07:00
Ralf Jung
f118ff43e7 implement the unchecked_ intrinsics; add all the doctests from one of the integer modules 2017-07-03 20:37:33 -07:00
Ralf Jung
440c4778fa validate size and alignment on reallocate and deallocate 2017-07-03 16:47:58 -07:00
Ralf Jung
dc9f5a205f properly check for: double-free, use-after-reallocate 2017-07-03 16:12:11 -07:00
Ralf Jung
030166757c Fix transmute on ByValPair
Fixes #227
2017-07-03 13:58:50 -07:00
Oliver Schneider
823b952ef2 Only check pointers when dereferencing
Before we also checked whether pointers had alloc_ids when we created rvalue references
2017-07-03 14:16:11 +02:00
David Renshaw
e3fa4fb849 get cargo-miri to work 2017-06-29 13:06:36 -04:00
Oliver Schneider
8722ce8d4b Merge pull request #223 from oli-obk/lvalue_read
Reinstate `eval_and_read_lvalue` optimizations
2017-06-29 15:40:06 +02:00
David Renshaw
73ab5c77c2 normalize signature before passing to check_sig_compat 2017-06-29 07:58:22 -04:00
David Renshaw
32e7dcb6fb update for upstream changes to TyFnDef 2017-06-28 22:00:17 -04:00
Oliver Schneider
695f9723d2 Merge pull request #222 from oli-obk/const_eval_checks
Address comments to previous PR
2017-06-28 23:08:58 +02:00
Ralf Jung
51b43215a4 cast -> transmute 2017-06-28 11:37:15 -07:00
Oliver Schneider
917c89e697 Optimize lvalue reads from Value::ByVal and Value::ByValPair 2017-06-28 13:37:23 +02:00
Oliver Schneider
91409f1d76 Code nits 2017-06-28 13:10:50 +02:00
Oliver Schneider
c8079c652c
Address comments 2017-06-28 10:17:14 +02:00
Oliver Schneider
a724a39323 Reword comments 2017-06-28 09:46:41 +02:00
Oliver Schneider
5dfaacf310 Simplify all the code 2017-06-27 13:36:41 +02:00
Oliver Schneider
ab400f3eea Initial work towards checking const eval rules in miri 2017-06-26 17:58:47 +02:00
Ralf Jung
76a1d66e77 fix build after rebase 2017-06-24 11:05:53 -07:00
Ralf Jung
38d03392fa Clarify pattern matching 2017-06-24 11:05:13 -07:00
Ralf Jung
b1acc130bb check alignment of pointers on Ref 2017-06-24 11:05:13 -07:00
Ralf Jung
f0c8df2291 handle ptr-int casts explicitly in cast.rs 2017-06-24 11:05:13 -07:00
Oliver Schneider
eca9e3429a PrimVal used to allow comparing Undef 2017-06-23 16:12:03 +02:00
Oliver Schneider
5ee4fdcd15 fetch_tls_dtor "read" an Undef as nonzero 2017-06-23 13:31:00 +02:00
Oliver Schneider
c4fc6c677d Typo 2017-06-23 13:30:31 +02:00
Oliver Schneider
9be3e9185b Remove the zst allocation 2017-06-23 12:55:49 +02:00
Ralf Jung
d5c031640f use PrimVal::to_bool rather than bytes_to_bool 2017-06-22 20:20:26 -07:00
Ralf Jung
14cb31fb88 permit bit-anding in pointer values below the alignment
This makes HashMap work!
2017-06-22 14:46:53 -07:00
Ralf Jung
269667e152 implement _nonzero intrinsics 2017-06-22 14:46:53 -07:00
Ralf Jung
c1a6df941e permit all kinds of 0-offsets on ZSTs 2017-06-22 14:26:17 -07:00
Ralf Jung
2f61356858 permit offsetting a NULL-ptr by 0, to fix hashmap test 2017-06-22 13:41:13 -07:00
Ralf Jung
57391bab10 fix unused variable warning 2017-06-22 11:33:39 -07:00
Ralf Jung
6512fa7be8 use PrimVal::is_null 2017-06-22 11:33:31 -07:00
Ralf Jung
3637aa86c8 allow any offset on integer pointers 2017-06-22 11:28:00 -07:00
Oliver Schneider
8de111018d Merge pull request #201 from oli-obk/test_suite_fails
"Support" more libc functions
2017-06-22 14:16:45 +02:00
Oliver Schneider
8733bd0e7c Update mod.rs 2017-06-22 11:40:06 +02:00
Oliver Schneider
a805606d45 malloc should return null for zst allocs 2017-06-22 08:52:53 +02:00
Ralf Jung
7b2b0dd56c test HashMap creation in libstd-MIR, and make it work again 2017-06-21 23:09:34 -07:00
Ralf Jung
894306e47d refactor pointer arithmetic handling 2017-06-21 22:59:47 -07:00
Ralf Jung
78aa93fa10 correctly reject functions pointers that had arithmetic done to them 2017-06-21 21:45:51 -07:00
Ralf Jung
7b1582b383 permit integer addition and subtraction on ptr-integers 2017-06-21 21:38:43 -07:00
Ralf Jung
b8c5e7fd0e refactor pointer handling in binops 2017-06-21 21:02:11 -07:00
Ralf Jung
184d3b3bad expand thread-local storage tests to cover dtor order and re-running dtors 2017-06-21 20:17:07 -07:00
Oliver Schneider
a630677b01 Report better errors on random numbers and threads 2017-06-21 16:34:40 +02:00
Oliver Schneider
ecc44fec7e Implement malloc and free 2017-06-21 15:51:42 +02:00