Commit Graph

2150 Commits

Author SHA1 Message Date
bors
6a0f14bef7 Auto merge of #1146 - RalfJung:rustup, r=RalfJung
Rustup
2020-01-15 18:36:23 +00:00
Ralf Jung
23c74449a2 rustup 2020-01-15 19:27:21 +01:00
bors
b4c54b4641 Auto merge of #1143 - christianpoveda:symlink-shim, r=RalfJung
Add shim for symbolic link creation

r? @RalfJung
2020-01-10 17:21:12 +00:00
Christian Poveda
5e71f2debc
fix windows symlink creation 2020-01-10 12:18:24 -05:00
Christian Poveda
0b5a30515e
small corrections 2020-01-10 12:01:05 -05:00
Oliver Scherer
dbffbe5214 Document all the things 2020-01-09 12:42:56 +01:00
Oliver Scherer
bfc7a7effd Remove trailing newline 2020-01-09 12:38:58 +01:00
Oliver Scherer
c69ebaaed2 Use names that actually represent what's going on 2020-01-08 13:43:23 +01:00
Oliver Scherer
90a8f2f6a3 Make the non-halting diagnostic scheme independent of InterpError 2020-01-08 13:02:55 +01:00
Oliver Scherer
c0a7fd5602 Remove debugging hint until we can actuall use note: 2020-01-08 12:50:15 +01:00
Oliver Scherer
aec175e0de Process delayed errors on every step 2020-01-08 12:49:46 +01:00
Oliver Scherer
bb58e42da2 Tell the user about stacked borrow debugging flags 2020-01-08 12:37:25 +01:00
Oliver Scherer
96d6efdf32 Emit errors without halting interpretation 2020-01-08 12:37:25 +01:00
Oliver Scherer
4411903cca Add a scheme for registering and obtaining errors even without access to an InterpCx 2020-01-08 12:37:25 +01:00
Oliver Scherer
4de031b3da Move error reporting to its own module 2020-01-08 12:37:25 +01:00
Oliver Scherer
2673ba99fd Trailing return 2020-01-08 12:37:25 +01:00
Oliver Scherer
b9f6b9721a Split error reporting from main eval function 2020-01-08 12:37:25 +01:00
Christian Poveda
91cf68fac5
Add lstat shim for macos 2020-01-07 12:26:23 -05:00
Christian Poveda
4a1dbc77dc
Add shim for symbolic link creation 2020-01-06 16:30:17 -05:00
Yuki Okushi
86ee705cd5 Rustup 2020-01-07 05:13:18 +09:00
Yuki Okushi
3607dafd9b More rustup 2020-01-05 21:24:28 -08: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
bors
39146c44bd Auto merge of #1130 - christianpoveda:ignore-close-read-only, r=RalfJung
Ignore close errors in read-only files.

this fixes https://github.com/rust-lang/miri/issues/999

r? @RalfJung
2019-12-31 11:00:08 +00:00
Christian Poveda
a40a99d849
avoid double negation 2019-12-30 17:26:17 -05:00
bors
9f79aa9bb4 Auto merge of #1131 - JOE1994:alloc_os_str_as_c_str, r=RalfJung
Add helper 'alloc_os_str_as_c_str' and use it in env_var emulation

First part of the plan laid out in #707 (comment).

Re-submitting a pull-request for work from  #1098 (manual rebasing..)

r? @RalfJung
2019-12-30 19:15:53 +00:00
Christian Poveda
ce4e1f9fe7
add comments 2019-12-29 22:51:48 -05:00
Christian Poveda
b7e6135d7b
Use Scalar::to_u16 2019-12-28 08:38:31 -05:00
JOE1994
a4bd68a45f Add helper 'alloc_os_str_as_c_str' and use it in env_var emulation 2019-12-27 20:32:20 -05:00
Christian Poveda
f00fd3990b
avoid excluding TERM env var 2019-12-27 08:37:52 -05:00
Christian Poveda
dc4b8ac2e6
close file silently if the file is read only 2019-12-27 08:34:35 -05:00
Oliver Scherer
4aef81eb85 Remove to_ptr uses 2019-12-27 14:26:05 +01:00
Christian Poveda
c8190e8de7
rename metadata struct 2019-12-26 19:31:59 -05:00
Christian Poveda
2151e958ce
minor fixes and updated docs 2019-12-26 12:12:27 -05:00
Christian Poveda
bbbb50a09a
set mask for statx correctly 2019-12-25 22:24:18 -05:00
Christian Poveda
1bc3629084
do padding correctly 2019-12-25 18:22:33 -05:00
Christian Poveda
d176259002
deduplicate shared code between stat and statx 2019-12-25 18:17:20 -05:00
Christian Poveda
515c119359
Add padding on 64-bits only 2019-12-25 13:10:50 -05:00
Christian Poveda
6d88a4704a
restrict stat shim to macos only 2019-12-25 12:38:35 -05:00
Christian Poveda
75f7a118e6
remove restrictions due to stat unavailability 2019-12-25 12:38:34 -05:00
Christian Poveda
dbc118919a
add padding to immediates 2019-12-25 11:08:27 -05:00
Christian Poveda
0184e10f2f
fix size for file mode 2019-12-25 08:27:50 -05:00
Christian Poveda
b2c4ff2aee
add remanining fields to stat stuct 2019-12-25 08:27:50 -05:00
Christian Poveda
6177e6df7e
provide correct name for shim 2019-12-25 08:27:50 -05:00
Christian Poveda
d9ecd77ada
add dummy stat shim 2019-12-25 08:27:49 -05:00
Ralf Jung
cd12f47af6 make bytes conversion functions private inside read/write functions 2019-12-24 11:46:02 +01:00
Ralf Jung
2db6a3c04d use new try_from methods 2019-12-24 11:43:42 +01:00
Oliver Scherer
bac261573f Rustup to rustc 1.42.0-nightly (005cf38f7 2019-12-22) 2019-12-23 23:02:36 +01:00
bors
02bba3f531 Auto merge of #1124 - RalfJung:sysroot-check, r=oli-obk
disable sysroot checks for distributed binaries

This should help with https://github.com/mozilla/nixpkgs-mozilla/issues/198.
2019-12-23 17:14:48 +00:00
Ralf Jung
e325ad24f2 support main functions with Result return type 2019-12-23 17:45:23 +01:00
Oliver Scherer
7ead530841 Rustfmt all the things 2019-12-23 12:56:23 +01:00
Ralf Jung
bc715cb646 disable sysroot checks for distributed binaries 2019-12-22 18:13:13 +01:00
bors
a3ea1cb458 Auto merge of #1101 - christianpoveda:stat-shim, r=RalfJung
Add statx shim for linux target

This is an attempt to fix: https://github.com/rust-lang/miri/issues/999 (for linux only)

Currently there is one problem that I haven't been able to solve. `std::fs::metadata` fails because the creation time is not available even though it is provided in the shim code.

In order to inform the caller that the field was provided, the `stx_flag` field must have the bits of `STATX_BTIME` set (which they are). The creation time is in the `stx_btime` field of the `statx` struct (see [1]). The relevant code in `libstd` is here (probably?): https://github.com/rust-lang/rust/blob/master/src/libstd/sys/unix/fs.rs#L322

Another important point is that we are just providing the fields that are available in "all" platforms (this is, without using any platform specific traits or so). This can be improved later.

References:
[1] Man page: http://man7.org/linux/man-pages/man2/statx.2.html
[2] libc `statx` struct: https://docs.rs/libc/0.2.63/libc/struct.statx.html

Edit: The problem is that my filesystem is not providing it and I thought all filesystems could provide it. I changed the code so it only provides those dates if they are available. now we are ready to go.

r? @RalfJung @oli-obk
2019-12-22 17:01:53 +00:00
Christian Poveda
b0c7625dd1
add statx shim for linux 2019-12-22 11:46:02 -05:00
Oliver Scherer
817f4159a2 Use the machine stop error instead of abusing other error kinds 2019-12-09 14:29:28 +01:00
Oliver Scherer
eab2538317 Rename track-id to track-pointer-tag 2019-12-08 12:20:51 +01:00
Oliver Scherer
67417945d4 Detect all variants of stack removals 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
67151a712d rustup 2019-12-08 10:32:50 +01:00
Ralf Jung
0a63637e66 fix all-targets build 2019-12-07 19:04:05 +01:00
Ralf Jung
e92d16d9cd add flag to ignore memory leaks 2019-12-07 13:44:48 +01:00
Ralf Jung
edac086f1c rustup for find_fn rename 2019-12-04 23:31:39 +01:00
Ralf Jung
94732aaf7b rename helper methods a bit 2019-12-04 10:43:36 +01:00
Ralf Jung
01f060b6da avoid allocation in read_os_string_from_c_string 2019-12-04 10:16:08 +01:00
Ralf Jung
808ac8f4b9 use write_os_str_to_c_string for unix arg passing 2019-12-04 09:58:10 +01:00
Ralf Jung
ab000997db use throw_machine_stop macro 2019-12-03 23:31:44 +01:00
Aaron Hill
a418fe9826
Rustup for BodyCache changes 2019-12-02 20:21:03 -05:00
Ralf Jung
8e3c3eccc4 panic errors are actually still possible 2019-12-02 16:04:31 +01:00
Ralf Jung
d43e394c46 fix init_allocation_extra 2019-12-02 16:04:31 +01:00
Ralf Jung
e77258322c some error classes should be impossible 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
b2cddd27bd better span for functions whose frame we push 'manually' 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
dcdd68b936 also indicate abort via new MachineStop variant 2019-12-02 09:13:58 +01:00
Ralf Jung
f3c00a447c use new MachineStop error variant 2019-12-02 09:05:35 +01:00
Ralf Jung
a971b8a2ae fix for GlobalCtxt changes 2019-11-30 12:05:35 +01:00
Ralf Jung
4a4886c0f0 avoid injected_panic_runtime which is going away 2019-11-29 21:37:59 +01:00
Ralf Jung
e5a81c6a2d fix comment 2019-11-29 11:08:27 +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
a04620eb69 only run leak test on clean platforms 2019-11-27 09:13:37 +01:00
Ralf Jung
824328c6d5 adjust for goto_block refactoring 2019-11-27 08:34:15 +01:00
Ralf Jung
5339d541ef cargo-miri: also find Rust sources when being run in a locally built, linked toolchain 2019-11-23 10:33:49 +01:00
Aaron Hill
a328683c4a
Add acos, asin, and atan foreign functions
I copied the tests from the docs pages
2019-11-21 17:33:30 -05:00
Aaron Hill
2176bf6cf0
Fix nits
Co-Authored-By: Ralf Jung <post@ralfj.de>
2019-11-20 13:52:04 -05:00
Aaron Hill
3102129316
Improve return code propagation.
Don't explicitly exit if we reported an evaluation error
2019-11-20 12:43:10 -05:00
Aaron Hill
2532b86a3b
Propagate the return code from the start lang item
Fixes #1064

This ensures that we set the error code properly when a panic unwinds
past `main`.

I'm not sure what the best way to write a test for this is
2019-11-19 17:25:09 -05:00
Aaron Hill
2750f60d4f
Update panic runtime comment 2019-11-19 15:33:14 -05:00
Aaron Hill
e02dc4af4b
Re-add comment 2019-11-19 15:31:37 -05:00
Aaron Hill
8936d67e7f
Delegate to the actual panic runtime crate 2019-11-19 10:11:25 -05: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
Ralf Jung
5345636f37 use new isize_max method in FS accesses; also check full buffers for validity 2019-11-17 09:54:09 +01:00
bors
9f1aec34e1 Auto merge of #1055 - RalfJung:panic-stub, r=RalfJung
minimal rustup for panic changes

Main patch by @Aaron1011
2019-11-17 08:21:42 +00:00
Ralf Jung
f2c0c44a09 remove some leftovers from the miri-control-attribute days 2019-11-17 09:20:50 +01:00
bors
2bdf163d69 Auto merge of #1053 - RalfJung:clean, r=RalfJung
remove no-longer-needed zero checks
2019-11-14 10:16:51 +00:00
Ralf Jung
c790317eb9 remove no-longer-needed zero checks 2019-11-14 10:30:00 +01:00
Ralf Jung
64244e9a18 do full deref-check before reborrowing 2019-11-14 10:24:02 +01:00
bors
09b0a8a813 Auto merge of #1022 - christianpoveda:fix-fd-access, r=RalfJung
Fix unchecked memory access for files

This PR takes care of two problems:

- It uses `Memory::(read|write)_bytes` to guarantee that memory accesses are checked (Fixes: https://github.com/rust-lang/miri/issues/1007)
- It removes the `(get|remove)_handle_and` methods which were a little bit cumbersome to use. In particular `remove_handle_and`, because we were using it to avoid borrowing issues before the `Evaluator::memory` field was public.

@RalfJung @oli-obk
2019-11-13 22:58:24 +00:00
Christian Poveda
4baef7120a Fix maximum isize value for target 2019-11-13 14:45:00 -05:00
Christian Poveda
edd0157069 Cap count twice 2019-11-13 11:57:20 -05:00
Steven Gu
ca983f5f80 Implments intrinsics::copysignf32 and intrinsics::copysignf64. 2019-11-13 17:41:09 +08: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
2c55a508e9 rustup 2019-11-11 21:25:57 +01:00
Christian Poveda
6e37f2f3e1 Cap count 2019-11-09 15:15:52 +01:00
Christian Poveda
10b93730d3 Fix merge conflicts 2019-11-09 10:42:45 +01:00
Ralf Jung
37b1190def rustup 2019-11-08 22:07:52 +01:00
Ralf Jung
9ca277f2e9 bump minimal xargo version so that it honors the lockfile 2019-11-08 16:36:57 +01:00
Christian Poveda
4bbaa72dc9 Use TryFrom instead 2019-11-07 20:50:16 +01:00
bors
0740a2040f Auto merge of #1037 - JOE1994:master, r=RalfJung
error code E0080 is no longer printed with MIRI error message

Thanks to help from @bjorn3, @RalfJung, and @oli-obk on issue #1035 , I fixed the miri code so that error code **E0080** is no longer printed out for MIRI evaluation errors. I tested my code in my Linux machine as below.
![image](https://user-images.githubusercontent.com/10286488/68264744-e71e6c80-0017-11ea-9028-f83e19164ea2.png)

Remaining concern is whether the variable name `new_tcx` which I used is misleading or not.

Fixes https://github.com/rust-lang/miri/issues/1035
2019-11-06 13:39:22 +00:00
YOUNGSUK KIM
e5675ab0fc follow-up to review 2019-11-06 08:25:00 -05:00
Ralf Jung
8b0c14f9f6 ptr_offset: handle negative offsets 2019-11-06 10:51:06 +01:00
Ralf Jung
4b9a7d8cff fix error message details 2019-11-06 09:24:26 +01:00
Ralf Jung
9eb4e00f6f refactor ptr_offset_inbounds: it can be reduced to check_ptr_access, after all! 2019-11-06 09:24:26 +01:00
YOUNGSUK KIM
2661295cdf error code E0080 is no longer printed with MIRI error message 2019-11-05 21:56:18 -05:00
Christian Poveda
f910ea135c Avoid using as cast 2019-11-05 16:47:24 -05:00
Christian Poveda
56c5e53553 Handle host's usize correctly 2019-11-04 09:38:21 -05:00
Christian Poveda
d0b4407b25 Fix casts for count check 2019-11-03 10:04:00 -06:00
Ralf Jung
955a26fb08 calling panic_if_uninhabited is not actually UB 2019-11-03 15:39:03 +01:00
bors
4f7171585f Auto merge of #961 - rust-lang:exact_div_reuse, r=RalfJung
Use the upstream `exact_div` implementation

introduced in https://github.com/rust-lang/rust/pull/63810
2019-11-03 09:16:55 +00:00
Ralf Jung
5a5fa15382 style 2019-11-03 10:03:30 +01:00
Oliver Scherer
7a39460e24 Use the upstream exact_div implementation 2019-11-03 09:34:48 +01:00
Ralf Jung
ddb1fc9205 store scalars where appropriate 2019-11-02 11:50:21 +01:00
Ralf Jung
1e0b398cb6 Windows cmdline: avoid accessing allocations directly 2019-11-02 11:48:28 +01:00
Ralf Jung
90634121b3 fix typo 2019-10-30 15:05:44 +01:00
Ralf Jung
15ae234a42 rustup for span in intrinsic emulation 2019-10-30 10:16:58 +01:00
Christian Poveda
06ef77bfef Check for usize to i64 overflows 2019-10-28 16:44:18 -05:00
Christian Poveda
122549fd09 Simplify read logic 2019-10-26 09:03:45 -05:00
Christian Poveda
d7967f6b05 Drop files explicitly when closing them 2019-10-26 08:54:02 -05:00
Ralf Jung
d8a3a1f09c rustup for projection interning 2019-10-26 09:33:24 +02:00
Christian Poveda
260b463bb0 Clean file handling functions 2019-10-24 09:34:48 -05:00
Ralf Jung
c87f106cac update comments and some tweaks 2019-10-24 10:27:14 +02:00
Ralf Jung
cf9340113e rustup: more flexible write_bytes avoids allocations and removes itertools dependency 2019-10-24 10:15:30 +02:00
bors
a05f2aa3ab Auto merge of #993 - christianpoveda:os_string_helper, r=RalfJung
Add OsString from/to bytes helper functions

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

r? @RalfJung
2019-10-23 16:52:52 +00:00
Ralf Jung
354de02c24 rustup; fix debugging 2019-10-23 16:33:54 +02:00
Christian Poveda
de12cbcb32 Fix documentation 2019-10-23 08:58:25 -05:00
Christian Poveda
fb4cb5bf4a Make size error distinguishable from other errors 2019-10-22 16:57:07 -05:00
Christian Poveda
be415dbeda Use new write_bytes method 2019-10-22 11:44:49 -05:00
Ralf Jung
db949af8ed fix field index 2019-10-22 10:43:16 +02:00
Ralf Jung
2690f5948a rustup: fix for write_bytes and new union rules 2019-10-22 10:13:11 +02:00
Christian Poveda
72bd25de83 Fix merge conflicts 2019-10-21 08:49:49 -05:00
Ralf Jung
d9aa20fb31 add some missing trailing full stops that slipped through review 2019-10-21 13:24:56 +02:00
bors
af3923bebc Auto merge of #991 - christianpoveda:errno-place, r=RalfJung
Change the last OS error location to a place

r? @RalfJung
2019-10-21 09:15:51 +00:00
bors
f912a8b054 Auto merge of #1010 - RalfJung:xargo, r=RalfJung
when xargo is manually specified, don't try to upgrade it
2019-10-21 08:45:54 +00:00
Ralf Jung
ebdb6d4df7 when xargo is manually specified, don't try to upgrade it 2019-10-21 10:25:47 +02:00
Christian Poveda
283a130dda Add docs for the new helper functions 2019-10-20 17:40:21 -05:00
Christian Poveda
9d50c5e758 Small corrections to docs 2019-10-20 07:55:26 -05:00
Christian Poveda
8a8fa53a5d Transform the last error place to an immediate instead 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
5c3c738c4b Make transformation to OS error explicit 2019-10-20 07:53:56 -05:00
Christian Poveda
338e51aa48 Rename consume_result 2019-10-20 07:53:55 -05:00
Christian Poveda
ed776f67ba Change last_error to a place 2019-10-20 07:42:59 -05:00
Christian Poveda
4232939319 Move last error functions to helpers 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
Christian Poveda
f7c6e0efbe Do additional bounds checks 2019-10-19 15:49:00 -05:00
Christian Poveda
ab059671cb Change comparison order for clarity 2019-10-19 14:13:49 -05:00
Ralf Jung
324fed316f print sysroot without any escaping 2019-10-19 16:38:37 +02:00
Ralf Jung
e574c77aa2 audit our bounds checks 2019-10-19 12:39:02 +02:00
Christian Poveda
0201cc5587 Fix writing errors 2019-10-18 15:28:06 -05:00
Christian Poveda
85941c7249 Rename write/read os string functions 2019-10-18 09:49:56 -05:00
Christian Poveda
68fec4b3fe Use conditional compilation properly and work with OsStrs instead 2019-10-18 09:49:56 -05:00
Christian Poveda
1241abbec4 Change helper functions to read/write 2019-10-18 09:49:55 -05:00
Christian Poveda
61da8b8428 Add OsString from/to bytes helper functions 2019-10-18 09:47:19 -05:00
Ralf Jung
5481afbaf6 cleanup now that borrow checker knows memory is a field 2019-10-18 11:33:12 +02:00
Yuki Okushi
a353e90eed Use memory field instead of memory() 2019-10-18 11:11:50 +09:00
Ralf Jung
2967d0d13a better error when using cargo-miri in a workspace 2019-10-16 22:03:44 +02:00
bors
358cfd290c Auto merge of #996 - christianpoveda:unsup-wo-isolation, r=RalfJung
Add function to error with enabled isolation

Fixes https://github.com/rust-lang/miri/issues/986
r? @RalfJung
2019-10-16 08:17:57 +00:00
bors
49cab51ac3 Auto merge of #987 - christianpoveda:check-unsupported-fs-flags, r=RalfJung
Error when there is an unsupported flag for opening a file

@RalfJung this is my attempt to check for undesired flags. I also changed fcntl to error when doing any other action besides getting the flags for a fd
2019-10-16 07:52:12 +00:00
Christian Poveda
24872230dc Check that access mode flags only use the first two bits 2019-10-15 08:01:07 -05:00
Christian Poveda
78311a7132 Add function to error with enabled isolation 2019-10-15 07:33:14 -05:00
Ralf Jung
4ba63fb0fc explain our shell encoding 2019-10-15 11:03:32 +02:00
bors
42c1e779cb Auto merge of #980 - JOE1994:master, r=RalfJung
change cargo-miri.rs to fix issue #978

In Windows 10, there was an issue with building MIRI locally and getting it running,
due to unpredictable backslash escaping issues in paths.
I added a code snippet that would only be compiled in Windows OS, which replaces all backslashes in paths to slashes.
This fix should only affect Windows users.
Building and testing MIRI locally now works fine after the fix.
![miri_result_after_fix0](https://user-images.githubusercontent.com/10286488/66260998-344abc80-e794-11e9-9d7c-b4ef098443de.PNG)

Fixes https://github.com/rust-lang/miri/issues/978
2019-10-15 08:22:26 +00:00
bors
d902a11575 Auto merge of #975 - christianpoveda:clock-shim, r=RalfJung
Add clock_gettime shim

r? @oli-obk

I think there is no way to do proper testing of this other than checking that miri does not crash when calling `clock_gettime`.
2019-10-15 07:36:42 +00:00
YOUNGSUK_KIM
65fd00665e remove unnecessary line break 2019-10-14 22:37:54 -04:00
YOUNGSUK_KIM
e06ce728ca Ralf Jung's great idea! 2019-10-14 20:57:57 -04:00
Christian Poveda
f9c768864a Use places instead of ptrs to write packed immtys 2019-10-14 16:00:40 -05:00
Christian Poveda
50618b55cd Error on negative times 2019-10-13 16:06:37 -05:00
Christian Poveda
f76f8ce63b Correct fcntl behavior 2019-10-12 20:12:26 -05:00
Christian Poveda
508df227e5 Group libc helper functions 2019-10-12 19:48:18 -05:00
Ralf Jung
19fb53e8a3 better debugging for sysroot check 2019-10-12 18:11:44 +02:00
Christian Poveda
d73fae1b28 Remove F_SETFD command 2019-10-11 12:20:06 -05:00
Christian Poveda
a1c6797c5c Error when there is an unsupported flag 2019-10-11 11:42:12 -05:00
Christian Poveda
2cbf4afa99 Split write_c_ints into less specific helper functions 2019-10-11 11:41:11 -05:00
Christian Poveda
87b210df6c Fix sign when number of seconds is zero 2019-10-11 11:39:32 -05:00
Christian Poveda
8f4d185d1b Move time related functions to its own module 2019-10-11 11:39:31 -05:00
Christian Poveda
b8ee90d22e Throw error instead of panicking for unfittable bits 2019-10-11 11:38:24 -05:00
Christian Poveda
9f24c12624 Add helper function to write structs 2019-10-11 11:38:22 -05:00
Christian Poveda
b7863f2509 Add gettimeofday shim for macOS 2019-10-11 11:36:33 -05:00
Christian Poveda
7a6df8504f Get size of integers using libc 2019-10-11 11:36:33 -05:00
Christian Poveda
adfa2eb062 Return negative times when the current time is before the unix epoch 2019-10-11 11:36:33 -05:00
Christian Poveda
fcf04b5425 Reduce size of nanoseconds 2019-10-11 11:36:33 -05:00
Christian Poveda
aa3e9703d1 Add clock_gettime shim 2019-10-11 11:36:33 -05:00
Christian Poveda
003b257f87 Change error handling style for consistency 2019-10-11 08:20:32 -05:00
Christian Poveda
60cf06a03f Use existing tcx instead 2019-10-11 04:20:18 -05:00
Christian Poveda
67ea454647 Correct style of comments 2019-10-11 04:17:43 -05:00
Christian Poveda
1c64f29811 Add comment for the flag diff check 2019-10-11 03:55:18 -05:00
Christian Poveda
12040aae88 Add comment explaining why buffer isn't overflowed 2019-10-11 03:43:20 -05:00
Christian Poveda
c8df0171e8 Move functions to eval libc constants to helpers 2019-10-11 01:53:31 -05:00
Christian Poveda
976c976f09 Rename shims::io to shims::fs 2019-10-11 01:49:28 -05:00
YOUNGSUK_KIM
610dbdd562 fixed cargo-miri bug for windows users 2019-10-10 11:03:20 -04:00
Christian Poveda
187361996f Add errno_location shim for MacOS 2019-10-08 10:22:39 -05:00
Christian Poveda
ffc47de1b9 Add unlink shim to delete files 2019-10-08 08:50:58 -05:00
bors
9d03dd6364 Auto merge of #977 - christianpoveda:last-error-ptr, r=oli-obk
Move last error into memory

These changes move the `Evaluator::last_error` into miri's memory and implement the `__errno_location()` shim (which is used by the file handling functions when they fail).
2019-10-08 13:21:05 +00:00
Christian Poveda
459c65a4f9 Add method to consume io::Error 2019-10-08 08:18:51 -05:00
Christian Poveda
887d748114 Add __errno_location shim 2019-10-07 09:15:37 -05: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
YOUNGSUK_KIM
2b3b865c28 change cargo-miri.rs to fix issue #978 2019-10-05 17:11:09 -04:00
Nicolas
0c4003631d
Add missing atomic_fence intrinsics as nops
Fixes #972
2019-10-05 06:12:37 -03:00
Christian Poveda
6c36a8c949 Return earlier when reading/writing 0 bytes 2019-10-02 09:12:03 -05:00
Christian Poveda
f5022b19d3 Fix dangling pointer bug for zero-sized reads 2019-10-02 08:43:23 -05:00
Christian Poveda
78e0d309ef Avoid early return after handles are removed 2019-10-01 14:07:45 -05:00
Christian Poveda
5a05c04c85 Correct name of each shim when erroring 2019-10-01 11:14:50 -05:00
Christian Poveda
cd495cb04f Add file writing capabilities 2019-10-01 11:10:37 -05:00
Christian Poveda
d0509d719c Add docs for helper functions 2019-10-01 10:31:04 -05:00
Christian Poveda
50be5a83c5 Remove return argument when fd is not found 2019-10-01 09:28:48 -05:00
Christian Poveda
644467c570 Add methods to handle invalid fides 2019-09-30 15:54:43 -05:00
Christian Poveda
efbe798e62 Avoid buffer allocation to read files 2019-09-30 14:21:45 -05:00
Christian Poveda
775246e329 Add method to consume std::io::Result 2019-09-30 14:08:12 -05:00
Christian Poveda
03ed4123c0 Add FileHandle struct 2019-09-30 11:51:09 -05:00
Christian Poveda
b540e5d24e Reserve fides for stdio and fix merge issues 2019-09-30 10:54:51 -05:00
bors
b625812092 Auto merge of #957 - christianpoveda:ptr-align-offset, r=RalfJung
Fixes for align_offset

This addresses @RalfJung's comments in https://github.com/rust-lang/miri/pull/945
2019-09-28 18:38:00 +00:00
Ralf Jung
63ea13ad0d fix miri-rustc-tests 2019-09-28 11:00:05 -04:00
Ralf Jung
28e814ab53 rustup 2019-09-28 10:37:48 -04:00
Oliver Scherer
9fdb347ad7 Rustup to sty -> kind changes 2019-09-26 11:41:11 +02:00
Christian Poveda
ca3a917a6f Enable close call for macos 2019-09-25 11:16:11 -05:00
Christian Poveda
01f64616ad Check that the only flag change is done to enable FD_CLOEXEC 2019-09-25 11:11:20 -05:00
Christian Poveda
3726081857 Add helper function to fetch libc constants 2019-09-25 10:49:12 -05:00
Christian Poveda
79b1f91f45 First version of file handling 2019-09-25 01:17:18 -05:00
Christian Poveda
0eed5e64de Add chdir shim 2019-09-24 15:50:00 -05:00
Christian Poveda
02261e4be2 Fix comments 2019-09-24 09:29:16 -05:00
Christian Poveda
e2c54e64d1 Ignore integers 2019-09-22 21:39:17 -05:00
Christian Poveda
f736636038 Throw unsupported error when alignment is not a power of two 2019-09-22 20:56:48 -05:00
Christian Poveda
0f58289b3d fetch ERANGE value from libc 2019-09-20 11:32:07 -05:00
Christian Poveda
c0a6b5ff69 Set errno when getcwd fails 2019-09-20 03:30:55 -05:00
Christian Poveda
49275d4269 Avoid writing more bytes than necessary 2019-09-20 02:13:48 -05:00
Christian Poveda
133c2b39db Only use getcwd without isolation 2019-09-19 10:32:18 -05:00
Christian Poveda
5cf90bc786 Add getcwd shim 2019-09-18 16:13:59 -05:00
Ralf Jung
39e2a76817 Merge remote-tracking branch 'origin/master' into rustup-retag 2019-09-18 11:22:12 +02:00
Christian Poveda
4a0b7446cf Move truncation from the main branch 2019-09-17 13:26:12 -05:00
Christian Poveda
881929f753 Add align_offset for integers 2019-09-17 11:47:01 -05:00
Ralf Jung
130f9488d3 rustup 2019-09-17 12:31:02 +02:00
Ralf Jung
8cd215dc97 remove libstd backtrace work-around 2019-09-16 22:22:54 +02:00
bors
d0a10507e4 Auto merge of #945 - christianpoveda:ptr-align-offset, r=oli-obk
Use libcore's align_offset

Related issue: https://github.com/rust-lang/miri/issues/873
2019-09-16 15:52:22 +00:00
Christian Poveda
55863cb88e Use force_ptr instead of assert_ptr 2019-09-16 10:16:06 -05:00
Ralf Jung
9e2107cef5 install ICE hook 2019-09-16 09:31:56 +02:00
Ralf Jung
1ef1d581d3 update for rustc changes 2019-09-15 23:27:58 +02:00
Santiago Pastorino
5ecb2d9356
Place projection field is now Box<[PlaceElem<'tcx>]> 2019-09-15 00:05:52 -03:00
bors
9a146243d0 Auto merge of #949 - RalfJung:ask-to-run, r=RalfJung
factor ask-to-run-command into helper function
2019-09-14 11:44:01 +00:00
Ralf Jung
78cfdcead2 temporarily enable backtrace feature 2019-09-14 13:06:20 +02:00
Ralf Jung
b245cb616e factor ask-to-run-command into helper function 2019-09-13 10:39:36 +02:00
Christian Poveda
fa20338c9a Use str::from_utf8 instead 2019-09-12 09:36:31 -05:00
Christian Poveda
62280b4b11 Use libcore's align_offset 2019-09-11 11:09:56 -05:00
Oliver Scherer
e479ab2640 Rustup 2019-09-06 11:10:24 +02:00
Christian Poveda
4afa3bccb0 Rewrite alloc_env_var 2019-08-29 15:03:10 -05:00
Christian Poveda
814fe99516 Add cargo-miri test for no isolation 2019-08-29 10:13:02 -05:00
Christian Poveda
9c54368cca Exclude TERM env var by default 2019-08-29 04:07:20 -05:00
bors
ee8afead51 Auto merge of #935 - christianpoveda:blacklist-env-vars, r=RalfJung
Exclude environment variables from host communication

related issue: #933

r? @RalfJung
2019-08-29 08:09:57 +00:00
Christian Poveda
abcda6dc94 Small corrections
Co-Authored-By: Ralf Jung <post@ralfj.de>
2019-08-29 03:08:58 -05:00
Christian Poveda
c1cec3b247 Exclude env vars using flag 2019-08-28 17:57:41 -05:00
Christian Poveda
1ae1d71938 Add -Zmiri-env-exclude flag 2019-08-28 17:57:35 -05:00
Ralf Jung
f3ff10005a small optimization 2019-08-28 18:45:10 +02:00
Ralf Jung
79dd70fd9b Stacked Borrows: don't read from memory during retagging 2019-08-28 18:41:30 +02:00
bors
283928ad55 Auto merge of #925 - christianpoveda:environ-shim, r=RalfJung
Write name and value for each env var

In order to res0lve https://github.com/rust-lang/miri/issues/756 is necessary to have the whole `"NAME=VALUE"` sequence of bytes written into memory instead of just the value.

This change does not affect the interface of the `shim::envs::EnvVars` type in any way.

r? @RalfJung @oli-obk
2019-08-27 15:59:32 +00:00
Christian Poveda
7d93cc7b5e Add docs 2019-08-27 08:45:37 -05:00
bors
2be0db4c0b Auto merge of #917 - RalfJung:isolation, r=oli-obk
change flag name: enable-communication -> disable-isolation

r? @oli-obk  -- I think this is a better name for the flag but it is still somewhat clumsy. Suggestions?
2019-08-27 10:02:07 +00:00
Ralf Jung
3a68d943ba rustup 2019-08-27 08:32:31 +02:00
Christian Poveda
ace3416cf2 Write name and value for each env var 2019-08-26 18:08:26 -05:00
Ralf Jung
c6c9276d61 bump Rust and xargo 2019-08-26 19:44:27 +02:00
Ralf Jung
97f9fb1284 change flag name: enable-communication -> disable-isolation 2019-08-23 23:29:11 +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
Christian Poveda
98129631b5 Use err_unsup_format instead 2019-08-20 12:20:50 -05:00
Christian Poveda
b44fd97af6 Use host's rng when communication is enabled 2019-08-19 10:43:09 -05:00
Ralf Jung
4f1c9bb607 adjust for typed binary/unary_op 2019-08-18 07:42:15 +02:00
bors
4f6f264c30 Auto merge of #909 - RalfJung:deny-warn, r=oli-obk
deny warnings on CI
2019-08-15 09:37:38 +00:00
Ralf Jung
f9241be734 fix warning 2019-08-15 11:24:04 +02:00
bors
c71b240f85 Auto merge of #863 - RalfJung:deref-checks, r=RalfJung
adjust tests for eager pointer checks on deref

The Miri side of https://github.com/rust-lang/rust/pull/63075.

Fixes https://github.com/rust-lang/miri/issues/447.
2019-08-15 09:11:08 +00:00
Ralf Jung
a801b0ba3f adjust for fn rename 2019-08-15 11:01:03 +02:00
Christian Poveda
aee8f173ec Delegate writing to emulate_foreign_item 2019-08-14 16:50:36 -05:00
Christian Poveda
41f8cfa30e Move env shims to its own module 2019-08-14 16:30:55 -05:00
bors
1f504ea7be Auto merge of #894 - christianpoveda:env-vars-communication, r=RalfJung
Enable env communication

related issue: https://github.com/rust-lang/miri/issues/800. r? @RalfJung
2019-08-14 18:58:06 +00:00
Christian Poveda
451a09a685 Remove tcx parameter for EnvVars::alloc_env_value 2019-08-14 13:54:57 -05: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
67d13577aa Move test env var to test_runner 2019-08-13 12:10:24 -05:00
Christian Poveda
666cd22fa6 Wrap hashmap for env vars in its own type 2019-08-13 11:34:43 -05:00
bors
47b227e24a Auto merge of #906 - RalfJung:tls, r=RalfJung
make TLS state private to TLS module
2019-08-13 11:32:25 +00:00
Ralf Jung
95fb11d51f make TLS state private to TLS module 2019-08-13 09:29:01 +02:00
Ralf Jung
7a9733929b it's called RUSTC_CTFE_BACKTRACE now 2019-08-12 08:26:11 +02:00
Ralf Jung
04892d9155 typo 2019-08-10 11:33:33 +02:00
Ralf Jung
0743ed631e clamp ldexp exponent to i16 2019-08-10 11:27:27 +02:00
Ralf Jung
3ae01a64bc also support scalbn itself 2019-08-10 11:22:32 +02:00
Ralf Jung
5e3035b6cb use apfloat for ldexp 2019-08-09 19:54:01 +02:00
Christian Poveda
e1d1cd191f Use ldexp from cmath instead 2019-08-08 15:45:58 -05:00
Ralf Jung
19367fd8de bump xargo version 2019-08-08 19:34:23 +02:00
Christian Poveda
253af9692a Fix formatting 2019-08-07 10:50:46 -05:00
bors
b12ebfc3de Auto merge of #895 - RalfJung:uninit, r=oli-obk
Revert "uninit intrinsic is gone"

This reverts commit fa290f1a48.
Uninit is [being reinstated](https://github.com/rust-lang/rust/pull/63343) because it breaks some broken code.
2019-08-07 12:42:19 +00:00
Ralf Jung
455531c564 Revert "uninit intrinsic is gone"
This reverts commit fa290f1a48.
Uninit is being reinstated because it breaks some broken code.
2019-08-07 10:49:36 +02:00
Christian Poveda
b731a6a15f Add support for env communication 2019-08-06 17:40:07 -05:00