Commit Graph

2448 Commits

Author SHA1 Message Date
Ralf Jung
78ce616490 implement float_to_int_unchecked 2020-04-12 12:01:20 +02:00
Ralf Jung
2a3ce5d618 there is no 'align_of_val' intrinsic 2020-04-12 11:04:18 +02:00
Ralf Jung
fd0957f5cd remove an intrinsic that was moved to rustc 2020-04-12 11:02:56 +02:00
Ralf Jung
6414003ab9 organize intrinsics into groups 2020-04-12 11:01:59 +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
2e82a8dc9e Auto merge of #1304 - RalfJung:backtrace-sep, r=RalfJung
add empty line before backtrace, to separate it from help text

I think this improves how things look, and makes it easier to see the help text (it currently kind of drowns next to the backtrace).

Before:
```
error: unsupported operation: Miri does not support threading
  --> /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/sys/unix/thread.rs:68:19
   |
68 |         let ret = libc::pthread_create(&mut native, &attr, thread_start, &*p as *const _ as *mut _);
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Miri does not support threading
   |
   = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
   = note: inside `std::sys::unix:🧵:Thread::new` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/sys/unix/thread.rs:68:19
   = note: inside `std:🧵:Builder::spawn_unchecked::<[closure@tests/compile-fail/thread-spawn.rs:6:19: 6:24], ()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/thread/mod.rs:492:26
   = note: inside `std:🧵:Builder::spawn::<[closure@tests/compile-fail/thread-spawn.rs:6:19: 6:24], ()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/thread/mod.rs:386:18
   = note: inside `std:🧵:spawn::<[closure@tests/compile-fail/thread-spawn.rs:6:19: 6:24], ()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/thread/mod.rs:619:5
note: inside `main` at tests/compile-fail/thread-spawn.rs:6:5
  --> tests/compile-fail/thread-spawn.rs:6:5
   |
6  |     thread::spawn(|| {});
   |     ^^^^^^^^^^^^^^^^^^^^
   = note: inside closure at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/rt.rs:67:34
   = note: inside closure at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/rt.rs:52:73
   = note: inside `std::sys_common::backtrace::__rust_begin_short_backtrace::<[closure@DefId(1:6030 ~ std[2f86]::rt[0]::lang_start_internal[0]::{{closure}}[0]::{{closure}}[0]) 0:&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/sys_common/backtrace.rs:130:5
   = note: inside closure at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/rt.rs:52:13
   = note: inside `std::panicking::try::do_call::<[closure@DefId(1:6029 ~ std[2f86]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/panicking.rs:331:40
   = note: inside `std::panicking::try::<i32, [closure@DefId(1:6029 ~ std[2f86]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe]>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/panicking.rs:274:15
   = note: inside `std::panic::catch_unwind::<[closure@DefId(1:6029 ~ std[2f86]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/panic.rs:394:14
   = note: inside `std::rt::lang_start_internal` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/rt.rs:51:25
   = note: inside `std::rt::lang_start::<()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/rt.rs:67:5
```
After:
```
error: unsupported operation: Miri does not support threading
  --> /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/sys/unix/thread.rs:68:19
   |
68 |         let ret = libc::pthread_create(&mut native, &attr, thread_start, &*p as *const _ as *mut _);
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Miri does not support threading
   |
   = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support

   = note: inside `std::sys::unix:🧵:Thread::new` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/sys/unix/thread.rs:68:19
   = note: inside `std:🧵:Builder::spawn_unchecked::<[closure@tests/compile-fail/thread-spawn.rs:6:19: 6:24], ()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/thread/mod.rs:492:26
   = note: inside `std:🧵:Builder::spawn::<[closure@tests/compile-fail/thread-spawn.rs:6:19: 6:24], ()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/thread/mod.rs:386:18
   = note: inside `std:🧵:spawn::<[closure@tests/compile-fail/thread-spawn.rs:6:19: 6:24], ()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/thread/mod.rs:619:5
note: inside `main` at tests/compile-fail/thread-spawn.rs:6:5
  --> tests/compile-fail/thread-spawn.rs:6:5
   |
6  |     thread::spawn(|| {});
   |     ^^^^^^^^^^^^^^^^^^^^
   = note: inside closure at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/rt.rs:67:34
   = note: inside closure at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/rt.rs:52:73
   = note: inside `std::sys_common::backtrace::__rust_begin_short_backtrace::<[closure@DefId(1:6030 ~ std[2f86]::rt[0]::lang_start_internal[0]::{{closure}}[0]::{{closure}}[0]) 0:&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/sys_common/backtrace.rs:130:5
   = note: inside closure at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/rt.rs:52:13
   = note: inside `std::panicking::try::do_call::<[closure@DefId(1:6029 ~ std[2f86]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/panicking.rs:331:40
   = note: inside `std::panicking::try::<i32, [closure@DefId(1:6029 ~ std[2f86]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe]>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/panicking.rs:274:15
   = note: inside `std::panic::catch_unwind::<[closure@DefId(1:6029 ~ std[2f86]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/panic.rs:394:14
   = note: inside `std::rt::lang_start_internal` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/rt.rs:51:25
   = note: inside `std::rt::lang_start::<()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/rt.rs:67:5
```

What do you think?
2020-04-10 09:29:35 +00: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
bors
d935f62172 Auto merge of #1157 - divergentdave:shim-pthread-try-lock, r=RalfJung
Add shims for RwLock::try_read/RwLock::try_write

This implements proper locking so that we can check for reentrancy and implement the `try_*` methods.

Fixes https://github.com/rust-lang/miri/issues/781
2020-04-06 13:55:53 +00:00
David Cook
0f5f0e1520 Fix spelling typo 2020-04-05 20:55:39 -05:00
David Cook
bc54c7628d Eagerly compute i32 and u32 layouts 2020-04-05 16:03:44 -05:00
David Cook
f9dc942cfd Changes to error handling 2020-04-05 13:53:03 -05:00
David Cook
e7944419d4 Use Deadlock machine stop uniformly 2020-04-05 12:44:23 -05:00
David Cook
100141f57c Remove null checks, fall through to UB upon deref 2020-04-05 12:32:09 -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
David Cook
8293d80b53 Set explicit return value size for windows shim 2020-04-05 10:36:14 -05:00
David Cook
e1a1592991 Set some explicit return value sizes 2020-04-05 10:35:08 -05:00
David Cook
37ddde9f70 Implement TryEnterCriticalSection 2020-04-05 10:33:32 -05:00
David Cook
7f6df15aa2 Rearrange functions 2020-04-05 10:32:06 -05:00
David Cook
c7466c9531 Add TerminationInfo::Deadlock, use in mutex shim 2020-04-05 10:32:01 -05:00
David Cook
735fc12e1a Handle variation in layout of pthread_mutex_t 2020-04-05 10:27:31 -05:00
David Cook
e5e3256b59 Address review comments 2020-04-05 10:10:35 -05:00
David Cook
ba3884dae6 Use checked addition/subtraction on lock counts 2020-04-05 10:08:39 -05:00
David Cook
141319a412 Refactor sync shims with setters and getters 2020-04-05 10:07:39 -05:00
David Cook
fd94255b9d Add comments explaining asserts 2020-04-05 10:06:37 -05:00
David Cook
d11315ebfb Fix misleading function names 2020-04-05 10:05:34 -05:00
David Cook
765050f302 Revise mutex/rwlock memory layout for macOS compat 2020-04-05 10:03:29 -05:00
David Cook
dd9896b0f8 Implement mutex and rwlock functions 2020-04-05 10:03:22 -05:00
David Cook
88f319fb4c Add failing tests for mutex and rwlock 2020-04-05 09:25:21 -05:00
David Cook
46679bc9ef Add shims for RwLock::try_read/RwLock::try_write 2020-04-05 09:25:21 -05:00
Stein Somers
e7fafa1904 Replace last_entry with last_key_value 2020-04-05 15:21:15 +02:00
Ralf Jung
95ea03c124 add empty line before backtrace, to separate it from help text 2020-04-05 10:20:12 +02:00
Ralf Jung
0eccf1d9aa update Windows leak comment 2020-04-05 09:42:39 +02:00
bors
26d7e9bd23 Auto merge of #1300 - RalfJung:rust-src, r=RalfJung
Rust bootstrap sysroot now has src in the same place as rust-src

So we can remove a special hack. I checked this locally to confirm it works.

Cc https://github.com/rust-lang/rust/pull/70642 @eddyb
2020-04-04 14:46:40 +00:00
Ralf Jung
bd9ec746a5 Rust bootstrap sysroot now has src in the same place as rust-src, so remove special hack 2020-04-04 12:07:22 +02:00
bors
0e8a1a40f2 Auto merge of #1294 - JOE1994:windows_instant, r=RalfJung
Add support for 'std::time::Instant' in Windows

Add support for creating `std::time::Instant` in Windows

Includes shims for `QueryPerformanceCounter` & `QueryPerformanceFrequency` in Windows, which are both called in Windows when `std::time::Instant` is created.

Windows docs page ["Acquiring high-resolution time stamps"](https://docs.microsoft.com/en-us/windows/win32/sysinfo/acquiring-high-resolution-time-stamps) was helpful in learning how `QueryPerformanceCounter` & `QueryPerformanceFrequency` work.

closes #1291
2020-04-03 06:36:15 +00:00
Ralf Jung
9f3383d55d rustup for import changes 2020-04-03 00:05:35 +02:00
Youngsuk Kim
f762c70b51
Update comments in src/shims/time.rs
Co-Authored-By: Ralf Jung <post@ralfj.de>
2020-04-02 16:04:50 -04:00
Youngsuk Kim
5157b8769f
Update comments in src/shims/time.rs
Co-Authored-By: Ralf Jung <post@ralfj.de>
2020-04-02 16:04:10 -04:00
Youngsuk Kim
a494825d5a
Update comments in src/shims/time.rs
Co-Authored-By: Ralf Jung <post@ralfj.de>
2020-04-02 16:03:56 -04:00
Ralf Jung
d5beecb79c correct factual mistake in Windows message, and use "+" sugar 2020-04-02 15:16:20 +02:00
Ralf Jung
5ce2466892 fix for FieldPlacement rename 2020-04-02 09:19:56 +02:00
Ralf Jung
f599687f3f adjust for span not being passed around any more 2020-04-02 09:14:17 +02:00
Ralf Jung
5130aa55a2 adjust stacktrace printing to rustc changes 2020-04-02 09:14:17 +02:00
JOE1994
ff982b1821 fix incorrect error message in shim 'QueryPerformanceCounter' 2020-04-01 21:26:47 -04:00
JOE1994
957ec2be10 Add support for 'std::time::Instant' in Windows 2020-04-01 20:35:56 -04:00
bors
6536f3165e Auto merge of #1290 - RalfJung:rustup, r=RalfJung
Rustup

Also remove ICEing `breakpoint` intrinsic shim.
2020-04-01 17:59:33 +00:00
Ralf Jung
1e3800ffb1 rustup 2020-04-01 19:40:10 +02:00
Ralf Jung
3911388e06 remove ICEin intrinsic 2020-04-01 19:12:26 +02:00
JOE1994
b3f9e53049 Implement 'GetSystemTimeAsFileTime' shim for Windows 2020-04-01 10:55:26 -04:00
Ralf Jung
1cfd80ea2d rustup; fix Windows env var memory type 2020-03-30 22:13:53 +02:00
bors
319f2dd9e1 Auto merge of #1279 - divergentdave:open_O_EXCL, r=RalfJung
Add support for OpenOptions::create_new()/O_EXCL

This PR extends the POSIX shim for `open` to support the `O_EXCL` flag, when it is used alongside `O_CREAT`, and exercises it by testing `OpenOptions::create_new`.
2020-03-30 15:49:45 +00:00
Ralf Jung
8948a29a4c adjust for librustc rename; reduce 'extern crate' to rustc crates 2020-03-30 11:07:32 +02:00
Ralf Jung
5ff7eef2ff rustup; fix for TyLayout rename 2020-03-30 10:23:04 +02:00
David Cook
808709c288 Add support for OpenOptions::create_new()/O_EXCL 2020-03-29 16:06:41 -05:00
JOE1994
ed1305d986 fix fn read_path_from_wide_str 2020-03-29 16:01:07 -04:00
JOE1994
a458cf3fe6 make 'fn convert_path_separator' to take Cow<> (to remove unnecessary allocation) 2020-03-29 14:19:59 -04:00
JOE1994
9bdb4bbbbf Move definition of 'fn windows_check_buffer_size' to top of 'src/shims/env.rs' 2020-03-29 13:13:42 -04:00
JOE1994
1b0abc5797 small refactorings to 'src/shims/os_str.rs' & 'src/shims/env.rs' 2020-03-29 13:10:23 -04:00
JOE1994
1667ded0d2 fix fn GetCurrentDirectoryW + clarify return types of Windows shims 2020-03-29 11:30:42 -04:00
JOE1994
7e0cc8307e fix 'magic boolean' to enum 2020-03-29 11:30:08 -04:00
JOE1994
fe9ecb50d1 Follow-up to reviews from RalfJung
1. Fix 'fn convert_path_separator' in src/shims/os_str.rs
2. Fix 'fn set_last_error_from_io_error' in src/helpers.rs
3. Minor comment fix for 'fn SetCurrentDirectoryW' in src/shims/env.rs
2020-03-29 11:30:08 -04:00
JOE1994
1141b21e50 Windows shims for GetCurrentDirectoryW/SetCurrentDirectoryW 2020-03-29 11:30:08 -04:00
JOE1994
a481b8f261 partially implement 'set_last_error_from_io_error' for Windows 2020-03-29 11:30:08 -04:00
Ralf Jung
f181e75db2 rustup 2020-03-29 10:01:31 +02:00
bors
7a5e95c9ac Auto merge of #1276 - RalfJung:scalar-precise-sizes, r=RalfJung
Construct Scalar with precise sizes
2020-03-28 18:16:13 +00:00
Ralf Jung
d6795a77b4 precise getrandom return type and align_offset arithmetic 2020-03-28 17:47:00 +01: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
ad14b684cc Auto merge of #1275 - JOE1994:move_string_helpers, r=RalfJung
move OsStr helpers to a separate file

Moved OsStr read/write functions from `src/helpers.rs` to `src/shims/os_str.rs`, in order to keep `src/helpers.rs` from bloating too much.
2020-03-28 15:32:16 +00:00
JOE1994
4a70ebc1f3 visually separate conditional imports in 'os_str.rs' 2020-03-28 11:20:16 -04:00
JOE1994
99600ba7a9 move OsStr helpers to a separate file 2020-03-28 10:43:47 -04:00
Ralf Jung
a6cab24dc0 we don't deallocate the environ global, so leave it in the machine 2020-03-28 14:32:50 +01:00
bors
f0afdc35d2 Auto merge of #1263 - RalfJung:shims-limit, r=RalfJung
Limit shims to libstd where possible

Also organize them better by category.
Fixes https://github.com/rust-lang/miri/issues/1181 (by making mmap not callable from user code)
2020-03-28 10:35:11 +00:00
Ralf Jung
6ab82f5d35 posix_fadvise is Linux-only; also validate arguments a bit 2020-03-28 11:33:56 +01:00
Ralf Jung
9e39bfbbd9 organize shims and make some only available to libstd as they are incomplete 2020-03-28 11:15:11 +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
02897e03cf cleanup tcx usage and a few comments 2020-03-28 09:50:24 +01:00
bors
f4308a0728 Auto merge of #1267 - RalfJung:macos-dtors, r=RalfJung
implement TLS cleanup for macOS

Now that I can run macOS interpretation locally, this was not that hard to fix. ;)
Fixes https://github.com/rust-lang/miri/issues/443
2020-03-28 07:55:42 +00:00
Ralf Jung
579b3c49da
adjust MemoryKind comment 2020-03-27 20:36:18 +01:00
Ralf Jung
da5f2f305b implement TLS cleanup for macOS 2020-03-27 19:39:00 +01:00
Youngsuk Kim
3fe71dff5a
Modify reference to issue 1013
Co-Authored-By: Ralf Jung <post@ralfj.de>
2020-03-27 10:15:35 -04:00
JOE1994
eaca17fcc3 add reference to issue#1013 2020-03-27 09:59:42 -04:00
JOE1994
f3e3af4bee adjust to change of 'fn write_os_str_to_wide_str' 2020-03-27 09:18:13 -04:00
JOE1994
4e38fbe6be follow-up2 to review (few issues not resolved yet) 2020-03-27 08:43:50 -04:00
JOE1994
2051805e95 follow-up to reviews 2020-03-27 08:43:50 -04:00
JOE1994
cf5822af46 exclude 'TERM' env_var to avoid terminfo trying to open the termcap file 2020-03-27 08:43:08 -04:00
JOE1994
2fa07009f2 Windows shims for env var emulation
Shims for GetEnvironmentVariableW / SetEnvironmentVariableW /
GetEnvironmentStringsW.
Passes test 'tests/run-pass/env.rs'
2020-03-27 08:43:08 -04:00
Ralf Jung
07f7083409
env: more precise error 2020-03-27 12:35:08 +01:00
JOE1994
813d76d948 follow-up to reviews 2020-03-27 07:07:21 -04:00
JOE1994
160ebaa364 add OS-specific handling to src/shims/env.rs 2020-03-27 00:10:45 -04:00
JOE1994
fc8f88e04e change helper fn 'write_os_str_to_wide_str' 2020-03-27 00:08:27 -04:00
Ralf Jung
81d505670b rustup; get rid of some try_from that are no longer needed 2020-03-26 00:11:50 +01:00
Ralf Jung
8ffbca797f bump xargo version 2020-03-25 12:11:05 +01:00
Ralf Jung
962e2105df remove an unnecessary as_str 2020-03-25 09:32:15 +01:00
Ralf Jung
47b91e619a test unreachable intrinsic 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
e9e04e56fc move path methods together, to the bottom of the string helpers 2020-03-24 09:11:48 +01:00
Ralf Jung
c4e29c8646 convert dir separators on path load/store 2020-03-24 09:11:48 +01:00
Ralf Jung
4ac91384ff route all path reading/writing through central read/write methods 2020-03-24 09:11:47 +01:00
bors
ad7089f194 Auto merge of #1258 - RalfJung:rustup, r=RalfJung
Rustup
2020-03-24 07:29:25 +00:00
Ralf Jung
87f5495715 32bit macOS is no more 2020-03-24 08:25:37 +01:00
Ralf Jung
80088e131b rustup for trait MachineStopType 2020-03-24 08:24:36 +01:00
JOE1994
5f9167bdaa helper functions for env_var emulation in Windows 2020-03-23 19:40:22 -04:00
Ralf Jung
284067cc15 rustup 2020-03-23 23:48:24 +01:00
Ralf Jung
2f371774ef fix conditional compilation condition for os_str <-> bytes conversion 2020-03-23 19:43:03 +01:00
Ralf Jung
b4b8750e44 bump Rust; HashMap should now work on macOS even with isolation 2020-03-23 10:34:15 +01:00
Ralf Jung
6e302b830a link to some websites for UB explanations 2020-03-22 23:32:19 +01:00
Ralf Jung
dd4fef0cd9 fix outdated sysroot help message 2020-03-22 20:09:14 +01:00
Ralf Jung
6dcca62b63 move -Zmiri-disable-isolation hint to help 2020-03-22 19:48:59 +01:00
Ralf Jung
a1b823886c give some context in error messages 2020-03-22 18:59:06 +01:00
Ralf Jung
d85f09c4e4 platform -> target 2020-03-22 08:55:39 +01:00
Ralf Jung
238ed49a07 detect UB: overflow in copy/write_bytes 2020-03-21 17:54:33 +01:00
Ralf Jung
6355228d4e remove no longer needed (and sometimes broken) 'extern crate' 2020-03-21 13:13:08 +01:00
bors
b2605d809d Auto merge of #1241 - RalfJung:dont-panic, r=RalfJung
whitelist platforms where panicking should work

@CAD97 [proposed](https://github.com/rust-lang/miri/issues/1059#issuecomment-601217992) trying to get a better error for failed panics on Windows.

Could you test if this works for you?
2020-03-21 09:55:23 +00:00
Ralf Jung
bde3111c61 test windows panic message 2020-03-21 10:17:57 +01:00
Ralf Jung
f430e54456 implement mach_absolute_time for macOS 2020-03-20 16:15:37 +01:00
Ralf Jung
04c937e281 assert platform in time shims 2020-03-20 15:11:54 +01:00
Ralf Jung
4608b94bd8 implement CLOCK_MONOTONIC on Linux 2020-03-19 23:01:24 +01:00
Ralf Jung
0f1713f67c whitelist platforms where panicking should work 2020-03-19 15:54:09 +01:00
Ralf Jung
681819c8ad getting a path should never fail
we basically treat them as lang items
2020-03-19 08:26:08 +01:00
Ralf Jung
e6e8773272 start messages in lower-case 2020-03-19 08:25:08 +01:00
Ralf Jung
1103a10e2c adjust for error reform 2020-03-19 08:25:08 +01:00
bors
6b56aefa0b Auto merge of #1239 - elichai:2020-03-abort-intrinsics, r=RalfJung
Abort instead of panic on asserting intrinsics

This fixes #1222
replacing the panic with an abort and a corresponding message.
the stack trace is already printed, this just adds an optional message the caller can pass, and I just pass the same message we passed to the panic but now to the abort instead.

r? @RalfJung
2020-03-18 12:20:30 +00:00
Elichai Turkel
52e1372e03
Abort instead of panic in asserting intrinsics, because they might not be panic safe 2020-03-18 14:14:23 +02:00
Elichai Turkel
1b8979c8c7
Add an optional message to abort 2020-03-18 14:14:23 +02:00
Ralf Jung
b82cf36117 rustup; remove no longer existing intrinsics 2020-03-17 21:11:19 +01:00
Ralf Jung
8b6af3eacb avoid using unchecked casts or arithmetic 2020-03-17 15:21:43 +01:00
Youngsuk Kim
a664156440
Minor typo fix
"initializiation" => "initialization"
2020-03-15 18:06:21 -04:00
Ralf Jung
17a677f4a9 abort intrinsic is handled by librustc_mir now 2020-03-15 11:17:07 +01:00
Ralf Jung
1c4f27f1b2 adjust Miri to needs of changed unwinding strategy 2020-03-15 10:59:07 +01:00
Ralf Jung
a92b2274ce fix typo and deduplicate comment 2020-03-14 12:05:25 +01:00
Ralf Jung
497fbcbf44 rustup, fix for intrinsic rename and transmute error change 2020-03-14 09:27:35 +01:00
Ralf Jung
13ae3147f0 refactor handling of diverging intrinsics/foreign functions 2020-03-12 21:20:16 +01:00
Ralf Jung
5531a79f4c rustup, test Abort terminator 2020-03-12 20:48:04 +01:00
bors
0f22d8a208 Auto merge of #1213 - lcnr:master, r=RalfJung
rm custom `intrinsics::discriminant_value`

@RalfJung requires https://github.com/rust-lang/rust/pull/69825
2020-03-12 16:50:12 +00:00
Ralf Jung
76ee8ff458 use ctfe_backtracte variable for backtrace control 2020-03-11 20:39:18 +01:00
Ralf Jung
45d5a37787 rustup+fix 2020-03-11 20:39:18 +01:00
Ralf Jung
548c90e102 share some code between panic intrinsics, and fix the message 2020-03-11 19:53:07 +01:00
Elichai Turkel
e81ebffa59
Implement panic_if_any_invalid and panic_if_zero_invalid intrinsics 2020-03-11 16:00:08 +02:00
Ralf Jung
8394456247 properly panic in panic_if_uninhabited and align_offset shims 2020-03-08 20:00:40 +01:00
Christian Poveda
5dc60d974b
move environ place to EnvVars 2020-03-08 11:58:20 -05:00
Ralf Jung
87dbf10e84 move environ init to update_environ 2020-03-08 17:21:02 +01:00
Christian Poveda
8392a0c589
only expose environ on linux 2020-03-08 10:16:31 -05:00
Bastian Kauschke
6fd3c9174c rm custom intrinsics::discriminant_value 2020-03-08 14:31:57 +01: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
Ralf Jung
7882dfb3f5
fix env update, and expand test 2020-03-06 08:21:53 -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
148269dd4b finally stop using min/max_value and the integer modules 2020-03-04 13:01:06 +01:00
bors
4f437099d8 Auto merge of #1202 - RalfJung:symbols, r=RalfJung
switch extern_statics map to symbols, and use FxHashMap everywhere

Cc @eddyb
2020-03-02 21:37:08 +00: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
68f70195fa rename xargo -> xargo_check 2020-03-02 22:10:48 +01:00
Aaron Hill
5960e8b80e
Rename XARGO env var to XARGO_CHECK
This reflects the fact that we want bootstrap to override `xargo-check`,
not `xargo
2020-03-02 14:17:14 -05:00
Ralf Jung
88c45f9891 adjust for rustc changes 2020-03-02 13:51:08 +01:00
Ralf Jung
59bddba5f3 remove unused import 2020-03-02 09:05:55 +01:00
Ralf Jung
90327335fc canonicalize alloc ID for ptr-to-int cast 2020-03-02 09:03:08 +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
48a4e3f4d8 format a few things 2020-03-01 11:54:19 +01:00
Ralf Jung
af98bd9a53 fix trailing indent in xargo files 2020-03-01 11:53:34 +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
Ralf Jung
2b04e3954a Remove incorrect try_lock from Windows critical section shim 2020-02-29 20:47:57 +01:00
Ralf Jung
5187e5ddd6 avoid Scalar::to_bits 2020-02-28 10:00:20 +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
62f9f4c578
fix Windows build failure 2020-02-26 15:15:16 +01:00
David Cook
df59d7ff74 Review comments 2020-02-26 07:59:11 -06:00
Ralf Jung
7e128beff9 fix build failures 2020-02-26 13:50:33 +01:00
David Cook
ad8c784009 Return length from write_os_str_to_c_str 2020-02-24 19:50:25 -06:00
David Cook
9e03b41338 Migrate readdir_r from pointers to places 2020-02-24 19:38:17 -06:00
David Cook
9fcc8a2a91 Review comments 2020-02-24 19:16:41 -06: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
Ralf Jung
443163f930 refactor cargo-miri a bit 2020-02-24 14:41:04 +01:00
Aaron Hill
e530829797 Use 'cargo check' to build the sysroot and target crate
Fixes #1057

Since we are no longer using "cargo rustc", we now use the rustc
arguments passed by Cargo to determine whether we are building a
build dependency, normal dependency, or "target" (final binary or test)
crate.
2020-02-24 14:41:04 +01:00
David Cook
dd00e5830f Use ID numbers in lieu of allocations for DIR* 2020-02-23 15:46:18 -06:00
David Cook
89cbe0ae56 Add comments 2020-02-23 15:45:04 -06:00
David Cook
725d6bfa9c Move error up, early return 2020-02-23 15:39:50 -06:00
David Cook
d6da4ab4b8 Add comments 2020-02-23 15:38:32 -06:00
David Cook
94f611348f Use os_str_length_as_c_str in readdir[64]_r 2020-02-23 15:37:22 -06:00
David Cook
947fa1fa26 Miscellaneous review comments 2020-02-23 15:36:03 -06:00
David Cook
d4b73efa81 Fix interpreted OS detection 2020-02-23 15:33:37 -06:00
David Cook
9a6921a17f Add doc comment inside DirHandler 2020-02-23 15:32:24 -06:00
David Cook
515d29aa2c Fix dirent layout for macOS 2020-02-23 15:31:07 -06:00
David Cook
ba61a9b37c Add shims for macOS-specific symbols 2020-02-23 15:26:42 -06:00
David Cook
974362ef64 Handle differing sizes of mode_t
mode_t is a u32 on Linux and a u16 on macOS
2020-02-23 15:08:44 -06:00
David Cook
5d35339111 Add shim for readdir64_r 2020-02-23 15:08:44 -06:00
David Cook
d7c3f588eb Add shims for opendir and closedir 2020-02-23 15:02:49 -06:00
David Cook
5b34f06bae Add shims for mkdir and rmdir 2020-02-23 15:02:49 -06:00
Ralf Jung
4a9a0a9078 avoid lowercasing platforms 2020-02-23 18:54:08 +01:00
Ralf Jung
e575fb1f57 improve comments 2020-02-23 18:52:12 +01:00
Ralf Jung
beb82ea4a4 add private helper trait for fs shim 2020-02-23 18:52:12 +01:00
Ralf Jung
5d35548985 helpers.rs cleanup 2020-02-23 18:52:12 +01:00
bors
2752d1b74b Auto merge of #1167 - christianpoveda:shims-refactor, r=RalfJung
Reorganize shims by platform

Fixes https://github.com/rust-lang/miri/issues/1161. I am currently testing which shims belong to which platform. If you are reading this and know the answer for any of those please write me :P

Edit: this is a list of the shims I haven't been able to figure out to which platform they belong:
 -~~`malloc`~~
 -~~`calloc`~~
 -~~`posix_memalign`~~
 -~~`free`~~
 -~~`realloc`~~
 -~~`__rust_alloc`~~
 -~~`__rust_alloc_zeroed`~~
 -~~`__rust_dealloc`~~
 -~~`__rust_realloc`~~
 -~~`__rust_maybe_catch_panic`~~
 -~~`syscall`~~
 -~~`getrandom`~~
 -~~`dlsym`~~
 -~~`memcmp`~~
 -~~`memrchr`~~
 -~~`memchr`~~
 -~~`strlen`~~
 -~~`signal`~~
 -~~`sigaction`~~
 -~~`sigaltstack`~~
 -~~`sysconf`~~
 -~~`sched_getaffinity`~~
 -~~`isatty`~~
 -~~`pthread_key_create`~~
 -~~`pthread_key_delete`~~
 -~~`pthread_getspecific`~~
 -~~`pthread_setspecific`~~
 -~~`pthread_attr_init`~~
 -~~`pthread_attr_destroy`~~
 -~~`pthread_self`~~
 -~~`pthread_attr_setstacksize`~~
 -~~`pthread_attr_getstack`~~
 -~~`pthread_create`~~
 -~~`pthread_mutexattr_init`~~
 -~~`pthread_mutexattr_settype`~~
 -~~`pthread_mutex_init`~~
 -~~`pthread_mutexattr_destroy`~~
 -~~`pthread_mutex_lock`~~
 -~~`pthread_mutex_unlock`~~
 -~~`pthread_mutex_destroy`~~
 -~~`pthread_rwlock_rdlock`~~
 -~~`pthread_rwlock_unlock`~~
 -~~`pthread_rwlock_wrlock`~~
 -~~`pthread_rwlock_destroy`~~
 -~~`pthread_condattr_init`~~
 -~~`pthread_condattr_setclock`~~
 -~~`pthread_cond_init`~~
 -~~`pthread_condattr_destroy`~~
 -~~`pthread_cond_destroy`~~
 -~~`pthread_atfork`~~
 -~~`posix_fadvise`~~
 -~~`mmap`~~
 -~~`mprotect`~~
2020-02-23 17:03:30 +00:00
Christian Poveda
208665836e
panic if target platform is incorrect instead 2020-02-22 09:02:29 -05:00
Christian Poveda
c2bcab55b0
improve docs 2020-02-22 08:55:45 -05:00
Christian Poveda
9e9a090026
minor fixes 2020-02-22 02:18:42 -05:00
Ralf Jung
08332bc730 dont overwrite bootstrap flags 2020-02-21 20:06:31 +01:00
Christian Poveda
bb3a711b3e
rename platform specific shims 2020-02-19 17:53:33 -05:00
Christian Poveda
3418b40dac
remove syscall shim from macos and move getrandom to linux module 2020-02-19 17:48:16 -05:00
Christian Poveda
b213f88b58
promote memrchr to work on any platform 2020-02-19 17:48:15 -05:00
Christian Poveda
9a7bc3972c
promote open and lseek shims to posix 2020-02-19 17:48:15 -05:00
Christian Poveda
dbef2340b2
add docs for `emulate_foreign_item_by_bame 2020-02-19 17:48:15 -05:00
Christian Poveda
32bc015e35
reorganize comments for shim's classification 2020-02-19 17:48:15 -05:00
Christian Poveda
bc7513bffd
move CreateThread to windows shims 2020-02-19 17:48:15 -05:00
Christian Poveda
1dbc0c9869
remove hack for panics 2020-02-19 17:48:15 -05:00
Christian Poveda
b819493585
move remaining shims 2020-02-19 17:48:15 -05:00
Christian Poveda
63160c66cd
move pthread related functions 2020-02-19 17:48:15 -05:00
Christian Poveda
8fe7543191
add helper function for target platform checks 2020-02-19 17:47:34 -05:00
David Cook
ae7d98b68f Extract constant for minimum fd 2020-02-18 18:06:33 -06:00
David Cook
8216f3c0f3 Back out placeholder variants from FileHandle 2020-02-17 22:24:33 -06:00
David Cook
a6a8f09f1e Address review comments 2020-02-17 22:24:33 -06:00
David Cook
962a740426 Rewrite file descriptor handling 2020-02-17 22:24:33 -06:00
David Cook
eda35e153b Add methods to FileHandler 2020-02-17 22:24:33 -06:00
David Cook
1de9d107cf Style fixes 2020-02-17 22:24:33 -06:00
David Cook
3aff803868 Add comment 2020-02-17 22:24:33 -06:00
David Cook
085874d1ff Add F_DUPFD/F_DUPFD_CLOEXEC to fcntl shim 2020-02-17 22:24:33 -06:00
bors
daaf9f7e28 Auto merge of #1177 - RalfJung:debug-assert, r=RalfJung
Make sure we evaluate debug assertions in local crate and libstd

Fixes https://github.com/rust-lang/miri/issues/1126
2020-02-16 13:04:06 +00:00
Ralf Jung
6ff5b3fcf9 make sure we also trigger debug assertions in libstd 2020-02-16 13:55:51 +01:00
Christian Poveda
c233c4ad9c
migrate more functions 2020-02-14 16:37:30 -05:00
Christian Poveda
f2f8fb2c20
migrate more functions 2020-02-14 16:37:30 -05:00
Christian Poveda
e7d6e718b9
reorganize shims by platform 2020-02-14 16:37:29 -05:00
bors
0a803c9752 Auto merge of #1158 - divergentdave:shim-rename, r=RalfJung
Add shim for rename

This adds a straightforward shim for rename, which is used by `std::fs::rename`. Testing is included.

As a heads up, I expect one or two merge conflicts between my PRs, since some of them touch the same `use` statements, or add items near the same places. I'll rebase and fix them as they come up.
2020-02-14 20:26:23 +00:00
Ralf Jung
26d25220ef fix for Panic InterpError refactoring 2020-02-13 14:01:35 +01:00
David Cook
38204b6321 Add shim for rename 2020-02-08 22:33:49 -06:00
bors
f9615bfd67 Auto merge of #1159 - divergentdave:shim-seek, r=RalfJung
Add shim for seeking files

This adds a shim for `lseek64` (`lseek` on macOS). This enables the use of `<File as Seek>::seek`. Testing is included.
2020-02-08 13:54:33 +00:00
Ralf Jung
4b6a0d7a8e bump rustc; adjust tests 2020-02-06 11:20:28 +01:00
bors
e7f5c4f155 Auto merge of #1151 - divergentdave:statx-AT_EMPTY_PATH, r=RalfJung
Add support for AT_EMPTY_PATH to statx shim

This enables use of `File::metadata()`.
2020-01-30 21:30:32 +00:00
Ralf Jung
ef154df607 pass MPlaceTy by-value, as we usually do 2020-01-30 13:38:49 +01:00
David Cook
2f25e4cd17 Error with EINVAL on unsupported whence argument 2020-01-29 19:04:18 -06:00
David Cook
6e9abea272 Update comment 2020-01-28 22:59:28 -06:00
David Cook
d8da3968d6 Change function name, comments, and error message 2020-01-28 19:43:55 -06:00
David Cook
0d0902a1e1 Apply shim to lseek too (for macOS) 2020-01-26 18:07:31 -06:00
David Cook
01b5e8260e Add no-op shim for posix_fadvise 2020-01-26 15:10:01 -06:00
David Cook
03b5d95cff Add shim for lseek64 2020-01-26 12:36:36 -06:00
David Cook
90f3aae2de Add fstat shim for OSX 2020-01-26 11:58:08 -06:00
David Cook
d94b88ef98 Add support for AT_EMPTY_PATH to statx shim 2020-01-25 22:21:33 -06:00
David Cook
625fa742bc
Shim intrinsics::atomic_singlethreadfence, etc. 2020-01-24 19:02:58 -06:00
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