Commit Graph

229 Commits

Author SHA1 Message Date
Ralf Jung
c379793cde add option to track call IDs 2020-07-02 10:33:54 +02:00
Ralf Jung
af5887e869 module organization: move platform-specific code to shims::{posix::{linux, macos}, windows} 2020-06-27 13:22:49 +02:00
Ralf Jung
17dd44ee92 rustup 2020-06-01 19:23:54 +02:00
Oliver Scherer
3fdab9c446 Update to rustc changes 2020-05-10 10:14:03 +02:00
Vytautas Astrauskas
69eaaadc28 Fix merge error. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
3bb1657448 Small style fix. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
688cacbdd7 Cleanup the implementation of adjust_global_const. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
552080a5b7 Fix imports. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
4609c3c520 Rename eval_maybe_thread_local_static_const to adjust_global_const. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
325c31e578 Address some of the reviewers comments. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
51b16e56cd Generate thread local allocations in eval_maybe_thread_local_static_const. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
963e9698f9 Generate fresh allocation ids for thread locals in eval_maybe_thread_local_static_const. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
d907fb5021 Rename ThreadSet to ThreadManager. 2020-04-27 14:23:32 -07:00
Vytautas Astrauskas
52184193c3 Fix comments in TLS. 2020-04-27 14:23:32 -07:00
Vytautas Astrauskas
ed9c7d168b Report that we do not support foreign thread local statics. 2020-04-27 14:23:32 -07:00
Vytautas Astrauskas
aef4c95599 Fix the problem of sending pointed to thread local statics. Add a regression test. 2020-04-27 14:23:32 -07:00
Vytautas Astrauskas
8dd8f199ca Update to support the updated API. 2020-04-27 14:23:32 -07:00
Vytautas Astrauskas
82f17ab917 Implement basic support for concurrency (Linux only). 2020-04-27 14:23:32 -07:00
Vytautas Astrauskas
192fd3d97e Move stack and stack_mut implementation in Machine to match their position in the trait. 2020-04-20 09:19:37 +02:00
Vytautas Astrauskas
5224c72403 Move the stack to the evaluator to make Miri compile with the newest Rustc. 2020-04-20 09:19:37 +02:00
Ralf Jung
14f50b34a3 use pre-computed layouts some more 2020-04-18 17:54:26 +02:00
Ozaren
b77968e8bd
added deallocation tracking 2020-04-15 11:29:35 -04:00
Ralf Jung
0805b4bf2e retag return places 2020-04-15 12:39:19 +02:00
Ralf Jung
90d71cd13f adjust for frame hook changes 2020-04-15 12:33:52 +02:00
Ralf Jung
fd8beaf5c4 add option to disable alignment checks 2020-04-13 17:58:03 +02:00
Ralf Jung
314e7238cf avoid a bunch of as_ref/as_mut 2020-04-12 10:32:36 +02:00
Ralf Jung
97791a56da avoid ref in matches 2020-04-12 10:08:12 +02:00
bors
325682ad56 Auto merge of #1301 - RalfJung:global-leaks, r=RalfJung
memory reachable through globals is not a leak

Blocked on https://github.com/rust-lang/rust/pull/70762
Fixes https://github.com/rust-lang/miri/issues/940
2020-04-07 17:33:24 +00:00
Ralf Jung
f462b4c257 memory reachable through globals is not a leak any more; adjust for better memory dumping 2020-04-07 19:03:41 +02:00
David Cook
bc54c7628d Eagerly compute i32 and u32 layouts 2020-04-05 16:03:44 -05:00
David Cook
79f3307f30 Update comments, rearrange code 2020-04-05 12:09:31 -05:00
David Cook
ac8c98da8e Store layouts of i32 and u32 inside Evaluator 2020-04-05 10:37:57 -05:00
Ralf Jung
9f3383d55d rustup for import changes 2020-04-03 00:05:35 +02:00
Ralf Jung
f599687f3f adjust for span not being passed around any more 2020-04-02 09:14:17 +02:00
Ralf Jung
8948a29a4c adjust for librustc rename; reduce 'extern crate' to rustc crates 2020-03-30 11:07:32 +02:00
Ralf Jung
b7fec6b17f use ptr_null where appropriate 2020-03-28 17:38:38 +01:00
Ralf Jung
fbbca59de7 avoid Scalar::from_(u)int in favor of giving the size explicitly 2020-03-28 17:35:40 +01:00
bors
b67dbca5d0 Auto merge of #1271 - RalfJung:env-clean, r=RalfJung
env shim: make sure we clean up all the memory we allocate

`Machine` memory is not leak-checked, so if we forgot to deallocate part of the env shim memory, we wouldn't even notice. Thus add a dedicated memory kind that is leak-checked.
2020-03-28 10:09:11 +00:00
Ralf Jung
204c13b8c7 env shim: make sure we clean up all the memory we allocate 2020-03-28 11:06:56 +01:00
Ralf Jung
876bded2e8 run Windows TLS dtor function 2020-03-28 10:39:29 +01:00
Ralf Jung
962e2105df remove an unnecessary as_str 2020-03-25 09:32:15 +01:00
Ralf Jung
9b0e9dec49 rustup, adjust for renames 2020-03-25 09:05:30 +01:00
Ralf Jung
d85f09c4e4 platform -> target 2020-03-22 08:55:39 +01:00
Ralf Jung
4608b94bd8 implement CLOCK_MONOTONIC on Linux 2020-03-19 23:01:24 +01:00
Elichai Turkel
1b8979c8c7
Add an optional message to abort 2020-03-18 14:14:23 +02:00
Ralf Jung
1c4f27f1b2 adjust Miri to needs of changed unwinding strategy 2020-03-15 10:59:07 +01:00
Ralf Jung
5531a79f4c rustup, test Abort terminator 2020-03-12 20:48:04 +01:00
Ralf Jung
45d5a37787 rustup+fix 2020-03-11 20:39:18 +01:00
Christian Poveda
5dc60d974b
move environ place to EnvVars 2020-03-08 11:58:20 -05:00
Christian Poveda
8392a0c589
only expose environ on linux 2020-03-08 10:16:31 -05:00
Christian Poveda
18a71ef7b3
minor corrections 2020-03-07 11:35:00 -05:00
Christian Poveda
e31b8b3342
add _NSGetEnviron foreign function for macos 2020-03-07 10:06:20 -05:00
Christian Poveda
aedc34c6e5
deallocate old environ 2020-03-06 18:11:05 -05:00
Christian Poveda
4f5fdc5810
update the environ shim when environment changes 2020-03-06 08:21:52 -05:00
Christian Poveda
d13fe01f82
add working shim for environ 2020-03-06 08:19:56 -05:00
Ralf Jung
ade4c4e733 make the new option actually do something 2020-03-06 09:11:41 +01:00
Ralf Jung
d82d701360 add option to track a particular AllocId (does nothing yet) 2020-03-06 09:06:23 +01:00
Ralf Jung
92a28f8d8f HashMap -> FxHashMap 2020-03-02 22:36:15 +01:00
Ralf Jung
0e021ad76c switch extern_statics map to symbols 2020-03-02 22:30:20 +01:00
Ralf Jung
59bddba5f3 remove unused import 2020-03-02 09:05:55 +01:00
Ralf Jung
8ef303cd32 port from find_foreign_static to canonical_alloc_id 2020-03-02 09:03:08 +01:00
Ralf Jung
5d8fbfcb5f rename memory kind: Env -> Machine 2020-03-02 09:01:23 +01:00
Ralf Jung
cc1ebd0af6 some formatting 2020-03-01 10:29:05 +01:00
Ralf Jung
ea5aa19487 rustup 2020-03-01 10:22:13 +01:00
bors
c0934e1eca Auto merge of #1152 - divergentdave:shim-directory, r=RalfJung
Add directory-related shims

This PR adds support for `mkdir`, `rmdir`, `opendir`, `closedir`, and `readdir64_r`.

Open directory streams are tracked through a HashMap indexed by pointer locations, which holds directory iterators. Since `DIR` is an opaque type in glibc, I represent them with 1-byte allocations, and then just use their pointers in HashMap lookups.

Tests are included to exercise the new functionality.
2020-02-26 14:15:55 +00:00
Ralf Jung
25ddc659d0 move validate field from memory to machine 2020-02-24 16:25:29 +01:00
Ralf Jung
274ae0438f add an option to disable Stacked Borrows 2020-02-24 16:22:02 +01:00
David Cook
d7c3f588eb Add shims for opendir and closedir 2020-02-23 15:02:49 -06:00
Ralf Jung
26d25220ef fix for Panic InterpError refactoring 2020-02-13 14:01:35 +01:00
Yuki Okushi
86ee705cd5 Rustup 2020-01-07 05:13:18 +09:00
Yuki Okushi
ebacb8ae4e Rustup 2020-01-05 15:55:15 -08:00
Adam Perry
0a3f460d69 Update panic machinery to match #[track_caller] changes.
This gets miri's tests passing again with https://github.com/rust-lang/rust/pull/67137.
2020-01-04 16:28:32 -08:00
Oliver Scherer
7ead530841 Rustfmt all the things 2019-12-23 12:56:23 +01:00
Oliver Scherer
eab2538317 Rename track-id to track-pointer-tag 2019-12-08 12:20:51 +01:00
Oliver Scherer
d363a47fcb Add a scheme to find the place where an id was destroyed 2019-12-08 12:20:51 +01:00
Ralf Jung
edac086f1c rustup for find_fn rename 2019-12-04 23:31:39 +01:00
Ralf Jung
01f060b6da avoid allocation in read_os_string_from_c_string 2019-12-04 10:16:08 +01:00
Ralf Jung
d43e394c46 fix init_allocation_extra 2019-12-02 16:04:31 +01:00
Ralf Jung
1b3434c67d adjust for init_allocation_extra 2019-12-02 16:04:31 +01:00
Ralf Jung
b91383b068 implement proper panicking for other MIR assertions
Requires generalizing the call_function helper to arbitrary Immediate arguments
2019-12-02 16:04:31 +01:00
Ralf Jung
8a36d12d36 implement proper panicking for failed index check 2019-12-02 16:04:31 +01:00
Ralf Jung
fe76d33506 Add and use helper function for calling a machine function and passing it some arguments 2019-11-29 09:23:29 +01:00
Ralf Jung
824328c6d5 adjust for goto_block refactoring 2019-11-27 08:34:15 +01:00
Ralf Jung
82374ad9bd comments and slight refactoring 2019-11-19 14:51:08 +01:00
Aaron Hill
08d3fbc76b
Support unwinding after a panic
Fixes #658

This commit adds support for unwinding after a panic. It requires a
companion rustc PR to be merged, in order for the necessary hooks to
work properly.

Currently implemented:
* Selecting between unwind/abort mode based on the rustc Session
* Properly popping off stack frames, unwinding back the caller
* Running 'unwind' blocks in Mir terminators

Not yet implemented:
* 'Abort' terminators

This PR was getting fairly large, so I decided to open it for review without
implementing 'Abort' terminator support. This could either be added on
to this PR, or merged separately.
2019-11-17 08:34:25 -05:00
Aaron Hill
cf5b53e52f
Rustup for panic changes
This gets Miri working again, but doesn't actually implement unwinding
2019-11-12 19:52:15 -05:00
Ralf Jung
ddb1fc9205 store scalars where appropriate 2019-11-02 11:50:21 +01:00
Ralf Jung
15ae234a42 rustup for span in intrinsic emulation 2019-10-30 10:16:58 +01:00
Ralf Jung
d9aa20fb31 add some missing trailing full stops that slipped through review 2019-10-21 13:24:56 +02:00
Christian Poveda
9d50c5e758 Small corrections to docs 2019-10-20 07:55:26 -05:00
Christian Poveda
619ccf3834 Rename set_last_error_from_io_result 2019-10-20 07:55:25 -05:00
Christian Poveda
ed776f67ba Change last_error to a place 2019-10-20 07:42:59 -05:00
Ralf Jung
88c88530ec use expect_none and unwrap_none where it makes sense 2019-10-20 12:20:48 +02:00
Yuki Okushi
a353e90eed Use memory field instead of memory() 2019-10-18 11:11:50 +09:00
Christian Poveda
11d7be9c6f Move last_error into memory 2019-10-07 09:15:32 -05:00
Christian Poveda
905c70cfa5 Rustfmt 2019-10-07 09:12:30 -05:00
Christian Poveda
79b1f91f45 First version of file handling 2019-09-25 01:17:18 -05:00
Ralf Jung
130f9488d3 rustup 2019-09-17 12:31:02 +02:00
Oliver Scherer
e479ab2640 Rustup 2019-09-06 11:10:24 +02:00
Ralf Jung
3a68d943ba rustup 2019-08-27 08:32:31 +02:00
bors
631d5facba Auto merge of #914 - christianpoveda:use-host-rng, r=RalfJung
Use host's rng when communication is enabled

This uses the host's randomness when the communication enabled flag is used. I am not sure about the error handling. I was thinking about fallbacking to `rand` if `getrandom` fails and also print something so the user knows miri is not using the host's rng because it failed. Let me know what you think.

Related issue: https://github.com/rust-lang/miri/issues/800.

r? @RalfJung @oli-obk
2019-08-23 09:52:54 +00:00
Christian Poveda
f53b5b0fb4 Update -Zmiri-enable-communication docs 2019-08-20 12:22:49 -05:00
Ralf Jung
4f1c9bb607 adjust for typed binary/unary_op 2019-08-18 07:42:15 +02:00
Christian Poveda
46f902b67d Rename export for shims::env::EnvVars 2019-08-14 11:31:29 -05:00
Christian Poveda
afc6713e41 Reorganize shims::env::EnvVars 2019-08-13 16:17:41 -05:00
Christian Poveda
666cd22fa6 Wrap hashmap for env vars in its own type 2019-08-13 11:34:43 -05:00
Christian Poveda
068c448832 Add communicate field to evaluator and fix formatting 2019-08-06 15:44:44 -05:00
Ralf Jung
b0cb603e3a rustup 2019-08-05 15:49:19 +02:00
Ralf Jung
f65e7cd2d1 adjust for rustc changes 2019-08-03 20:31:33 +02:00
Ralf Jung
bb6a91dc94 adjust for ptr_op now being called type-based 2019-08-03 14:38:36 +02:00
Ralf Jung
8071034b93 fix for error refactoring 2019-08-03 10:25:55 +02:00
Ralf Jung
068517ae66 make sure we always have an RNG 2019-07-23 21:38:53 +02:00
Ralf Jung
a2541aacd6 bump rust 2019-07-21 11:56:10 +02:00
Ralf Jung
9e130c6c6f fix for changd machine trait signatures 2019-07-06 10:07:22 +02:00
Ralf Jung
4f6a56f54f better error message when the program tries to spawn a thread 2019-07-06 10:07:21 +02:00
Ralf Jung
2ca1b94e6d update to FnVal changes; implement basic Dlsym support and use it for getentropy 2019-07-06 10:07:21 +02:00
Ralf Jung
b324cbf282 Merge remote-tracking branch 'origin/master' into rustup 2019-07-06 09:29:17 +02:00
Ralf Jung
1729965808 rename InterpretCx -> InterpCx 2019-07-05 23:48:51 +02:00
Ralf Jung
f23b782101 align small malloc-allocations even less, and test that we do 2019-07-05 23:48:48 +02:00
Ralf Jung
eb4128fb42 don't call Stacked Borrows hooks at all when validation is disabled 2019-07-03 10:47:28 +02:00
Ralf Jung
e82693fa23 Merge branch 'master' into rustup 2019-07-01 13:01:28 +02:00
Ralf Jung
11457a4ad9 fix comparing function pointers with intptrcast 2019-06-30 11:21:31 +02:00
bors
1ec279f290 Auto merge of #801 - RalfJung:num_cpus, r=RalfJung
support num_cpus crate and test that

Also make some magic numbers into proper global constants.
2019-06-30 08:42:25 +00:00
Ralf Jung
ba47d73041 Merge branch 'master' into rustup 2019-06-29 16:19:27 +02:00
Ralf Jung
019ad4bab4 move constants to machine.rs 2019-06-29 14:37:41 +02:00
Ralf Jung
c0b44ca98c tweak inttoptr allocation behavior
- Make `align_addr` not offset by `align` for no reason.
- Add some random slack between allocations to give them the chance to not be aligned.
2019-06-29 14:31:54 +02:00
Ralf Jung
aa5a9bc152 some module comments 2019-06-29 14:15:05 +02:00
Ralf Jung
857305ff67 Merge remote-tracking branch 'ralf/machine' into rustup 2019-06-29 14:04:50 +02:00
Ralf Jung
67d3779b0c move most of the stuff from lib.rs into machine.rs, and initialization + main loop into eval.rs 2019-06-29 13:48:59 +02:00