Commit Graph

948 Commits

Author SHA1 Message Date
bors
23a9d02748 Auto merge of #1933 - 5225225:1931-condvar-false-positive, r=RalfJung
Fix false positive use of uninit bytes when calling `libc::pthread_condattr_destroy`

Fixes: #1931
2021-12-08 14:51:53 +00:00
5225225
a4b2fc0c5a Adjust pthread tests 2021-12-06 21:50:14 +00:00
bors
81e59e6b92 Auto merge of #1930 - tavianator:avoid-adjacent-allocations, r=RalfJung
intptrcast: Never allocate two objects directly adjecent

When two objects directly follow each other in memory, what is the
provenance of an integer cast to a pointer that points directly between
them?  For a zero-size region, it could point into the end of the first
object, or the start of the second.

We can avoid answering this difficult question by simply never
allocating two objects directly beside each other.  This fixes some of
the false positives from #1866.
2021-12-06 01:33:55 +00:00
Ralf Jung
6a98c64c8b
final tweaks 2021-12-05 20:33:20 -05:00
5225225
eadeedde42 Handle uninit data in pthread_condattr_destroy 2021-12-05 19:47:29 +00:00
Ralf Jung
d537ed401d rustup 2021-12-05 11:02:20 -05:00
Tavian Barnes
b0a463334c intptrcast: Never allocate two objects directly adjecent
When two objects directly follow each other in memory, what is the
provenance of an integer cast to a pointer that points directly between
them?  For a zero-size region, it could point into the end of the first
object, or the start of the second.

We can avoid answering this difficult question by simply never
allocating two objects directly beside each other.  This fixes some of
the false positives from #1866.
2021-12-03 17:00:06 -05:00
Ralf Jung
ee666d8987 add tests for alignment on array initialization 2021-11-28 10:07:31 -05:00
Ralf Jung
4414d96323 implement shl and shr SIMD intrinsics 2021-11-25 17:26:37 -05:00
Ralf Jung
a534bbbf8a portable SIMD: add rem intrinsic; test div and rem intrinsic UB 2021-11-25 17:13:33 -05:00
bors
4f0faed6d2 Auto merge of #1922 - RalfJung:async-run-fut, r=RalfJung
async-fn test: make run_fut more general and entirely safe
2021-11-23 19:44:55 +00:00
Ralf Jung
c4502cbbe8 async-fn test: make run_fut more general and entirely safe 2021-11-23 14:33:00 -05:00
Ralf Jung
7dd1f0571c test for overflow-checks=off 2021-11-23 14:07:46 -05:00
Ralf Jung
b816cb94e7 implement SIMD sub, mul, div; also test i32 binops 2021-11-20 22:30:49 -05:00
Ralf Jung
0766da6fbe implement simd_add 2021-11-20 22:30:49 -05:00
Ralf Jung
d8bee92aee rename track-raw-pointers flag to tag-raw-pointers 2021-11-13 15:48:27 -05:00
Noah Lev
b3be6b44b6 Add tests for -Zmiri-check-number-validity 2021-11-10 11:36:42 -08:00
Ralf Jung
a6b12c229b rustup; add swap_remove test 2021-10-21 09:49:19 -04:00
Ralf Jung
f040413af8 rustup 2021-10-12 11:39:06 -04:00
Noah Lev
e751c7b04e rustup 2021-10-07 11:52:11 -07:00
DrMeepster
e6a27a68fa implement #[global_allocator] 2021-09-28 20:32:53 -07:00
hyd-dev
9a877b80fe
Add #[allow(dead_code)] in some tests 2021-09-11 18:58:57 +08:00
DrMeepster
84b058ac47 add support for #[start] 2021-09-02 15:41:10 -07:00
hyd-dev
7301fe118a
Move #[allow(unreachable_code)] in tests/run-pass/generator.rs 2021-08-26 16:16:43 +08:00
hyd-dev
33a67c6b33
Add #[allow(unreachable_code)] to drop(x) in tests/run-pass/generator.rs 2021-08-24 18:50:41 +08:00
niluxv
083e5e604c Add test for volatile_set_memory 2021-08-23 12:42:13 +02:00
hyd-dev
838ed1d754
Update tests for #[no_mangle] associated functions 2021-08-15 17:21:33 +08:00
hyd-dev
af7eb369b1
Fix tests for C-unwind ABI changes 2021-08-07 15:57:54 +08:00
bors
02f78b089c Auto merge of #1858 - RalfJung:thread-leaks, r=oli-obk
also ignore 'thread leaks' with -Zmiri-ignore-leaks

This is a step towards https://github.com/rust-lang/miri/issues/1371. The remaining hard part would be supporting checking for memory leaks when there are threads still running. For now we elegantly avoid this problem by using the same flag to control both of these checks. :)
2021-07-27 12:23:56 +00:00
Ralf Jung
78bcd12b17 make sure we only terminate main thread once TLS is initialized 2021-07-27 14:05:37 +02:00
Ralf Jung
66aa3d0247 make the loop infinite 2021-07-27 13:58:55 +02:00
Ralf Jung
679d10f98b no concurrency on windows 2021-07-25 14:38:02 +02:00
Ralf Jung
71efd950d1 also ignore 'thread leaks' with -Zmiri-ignore-leaks 2021-07-25 14:21:06 +02:00
Smit Soni
da6880427a Update error code for fs ops in isolation
Change the code to either `EACCES` (if the op is performed on the
path), or `EBADF` (if the op is performed the fd)

Updated ops: `stat`, `opendir`, `ftruncate64`, and `readlink`

Add a new test for fs ops in isolation.
2021-07-20 08:23:51 -07:00
Ralf Jung
6ce77164c1 rustup 2021-07-20 12:18:59 +02:00
Ralf Jung
bf8b2aa8dc add test for better ptr handling in enum niches 2021-07-17 13:59:58 +02:00
Aaron Hill
811423e761
Rustup for #[track_caller] trait object changes
Change test to assert that we get the correct location
even through a trait object call.
2021-07-10 11:51:00 -05:00
Ralf Jung
833dff994f rustup 2021-07-07 09:33:01 +02:00
hyd-dev
2644647053
Update backtraces 2021-06-20 15:12:11 +08:00
bors
486b5dfe74 Auto merge of #1832 - hyd-dev:1776-follow-up, r=RalfJung
Report an error if a `#[no_mangle]`/`#[export_name = ...]` function has the same symbol name as a built-in shim

Implements https://github.com/rust-lang/miri/pull/1776#issuecomment-821322605.

The error looks like this:
```
error: found `malloc` symbol definition that clashes with a built-in shim
  --> tests/compile-fail/function_calls/exported_symbol_shim_clashing.rs:12:9
   |
12 |         malloc(0);
   |         ^^^^^^^^^ found `malloc` symbol definition that clashes with a built-in shim
   |
help: the `malloc` symbol is defined here

  --> tests/compile-fail/function_calls/exported_symbol_shim_clashing.rs:2:1
   |
2  | / extern "C" fn malloc(_: usize) -> *mut std::ffi::c_void {
3  | |     //~^ HELP the `malloc` symbol is defined here
4  | |     unreachable!()
5  | | }
   | |_^
   = note: inside `main` at tests/compile-fail/function_calls/exported_symbol_shim_clashing.rs:12:9
```

This does not implement "better error messages than we do currently for arg/ABI mismatches" in https://github.com/rust-lang/miri/pull/1776#issuecomment-821343175 -- I failed to remove all `check_arg_count()` and `check_abi()` (they are still used in `src/shims/intrinsics.rs` and `call_dlsym()`) and they don't receive the name of the shim.
2021-06-15 09:53:05 +00:00
hyd-dev
dfd7a6d5aa
Rustup 2021-06-15 16:12:47 +08:00
hyd-dev
c822ec59aa
Implement cache for not found symbols 2021-06-11 15:24:51 +08:00
hyd-dev
6aef1d687d
Remove erroneous exit() and ExitProcess() in tests/run-pass/function_calls/exported_symbol.rs 2021-06-11 13:32:00 +08:00
hyd-dev
4f3718ef85
Fix the wrong EmulateByNameResult::NotSupported in syscall shim 2021-06-11 11:44:57 +08:00
bors
e5c3af6f51 Auto merge of #1818 - landaire:feature/panic-on-unsupported-syscalls, r=RalfJung
Add support for panicking in the emulated application when unsupported functionality is encountered

This PR fixes #1807 and allows an optional flag to be specified to panic when an unsupported syscall is encountered. In essence, instead of bubbling up an error in the context of the Miri application Miri will panic within the context of the *emulated* application. This feature is desired to allow CI pipelines to determine if a Miri failure is unsupported functionality or actual UB. Please read [this comment](https://github.com/rust-lang/miri/issues/1807#issuecomment-845425076) for the rationale behind this change.

Note: this change does not cover all cases where unsupported functionality errors may be raised. If you search the repo for `throw_unsup_format!` there are many cases that I think are less likely to occur and may still be problematic for some folks.

TODO:

- [x] README documentation on this new flag
- [x] Add tests
2021-06-09 18:09:06 +00:00
Ralf Jung
a38f02c44c isolated operations return EPERM; tweak isolation hint 2021-06-09 18:24:59 +02:00
Smit Soni
892f706ce5 Add a support to execute isolated op without halting
In user interface, added a new flag `-Zmiri-isolation-error` which
takes one of the four values -- hide, warn, warn-nobacktrace, and
abort. This option can be used to configure Miri to either abort or
return an error code upon executing isolated op. If not aborted, Miri
prints a warning, whose verbosity can be configured using this flag.

In implementation, added a new enum `IsolatedOp` to capture all the
settings related to ops requiring communication with the
host. Old `communicate` flag in both miri configs and machine
stats is replaced with a new helper function `communicate()` which
checks `isolated_op` internally.

Added a new helper function `reject_in_isolation` which can be called
by shims to reject ops according to the reject_with settings. Use miri
specific diagnostics function `report_msg` to print backtrace in the
warning. Update it to take an enum value instead of a bool, indicating
the level of diagnostics.

Updated shims related to current dir to use the new APIs. Added a new
test for current dir ops in isolation without halting machine.
2021-06-09 05:50:52 -07:00
hyd-dev
23c0495ebd
Update Box<Any> to Box<dyn Any> in catch_panic.stderr 2021-06-08 22:18:27 +08:00
Lander Brandt
ae237098f8 Add support for panicking in the emulated application when unsupported syscalls are encountered 2021-06-07 15:21:53 -07:00
hyd-dev
d7aff96053
Remove 2 tests 2021-06-06 11:22:25 +08:00
hyd-dev
879000b133
Detect std by checking if the crate defines #[lang = "start"] rather than string comparison 2021-06-06 11:12:05 +08:00
bors
28717a0e90 Auto merge of #1776 - hyd-dev:1170, r=RalfJung
Implement calls to exported symbols (#1170)

Closes #1170.
2021-06-03 15:59:56 +00:00
Pointerbender
386863ac53 added a strings.rs regression test case for potential future UB 2021-06-03 17:25:23 +02:00
hyd-dev
ba3b11fa42
Remove some tests 2021-06-03 14:16:58 +08:00
Pointerbender
c6dbe5cdca use references so that potential aliasing bugs are triggered during regression test 2021-06-02 15:36:18 +02:00
Pointerbender
b8aba11de3 regression tests for pointer invalidation in core library slice methods 2021-06-02 15:36:18 +02:00
hyd-dev
a952787163
Improve tests 2021-05-31 11:57:16 +08:00
hyd-dev
45832d4031
Remove duplicated "foreign function" 2021-05-31 11:57:15 +08:00
hyd-dev
41f33a64f8
Implement calls to exported symbols 2021-05-31 11:15:29 +08:00
hyd-dev
71f4140550
Add -Zmiri-disable-abi-check 2021-05-31 11:14:23 +08:00
Ralf Jung
7af7e9e4f3 rustup 2021-05-11 15:32:05 +02:00
Ralf Jung
a2b227f95a stacked borrows: ensure array-to-elem casts behave correctly 2021-05-07 09:24:33 +02:00
hyd-dev
b30c5fef5b
Rustup for rust-lang/rust#84401 2021-04-30 19:35:59 +08:00
Ralf Jung
4c741e5fb2 rustup 2021-04-25 16:57:48 +02:00
Ralf Jung
2ae699c56d make TLS-drop-test more cross-platform 2021-04-20 09:59:26 +02:00
Ralf Jung
d512ba2ae2 test thread_local_const_init 2021-04-18 11:01:08 +02:00
Charles Lew
85f7dd6131 Remove main_fn.rs test. 2021-04-17 00:04:09 +08:00
Ralf Jung
0674d439b6 test calling pthread_cond_timedwait with an already elapsed timeout 2021-04-11 14:21:42 +02:00
hyd-dev
3dff1d4fcd
Don't use MIRI_DEFAULT_ARGS to compile host crates 2021-04-09 00:57:59 +08:00
Mara Bos
90e218ad90 Fix panic test. 2021-03-08 17:06:50 +01:00
Mara Bos
5bd5ea21ea Remove unwrap_none as it won't be stabilized.
This upgrades to the latest rustc to be able to use try_insert()
instead.
2021-03-08 16:59:20 +01:00
Henry Boisdequin
f8440d6c99 Add in atomic_{min,max}_x intrinsics
Co-authored-by: Greg Bowyer <gbowyer@fastmail.co.uk>
2021-03-02 20:17:05 +05:30
Caleb Zulawski
dd81fb3f10 Remove non-power-of-two SIMD vectors 2021-02-08 00:17:24 -05:00
Mara Bos
7fc24442bd Update rust version.
- Allow new non_fmt_panic lint in test.
- Remove stabilized feature(wake_trait).
2021-02-05 10:08:05 +01:00
Ralf Jung
6f5a91f70a rustup 2021-01-31 13:12:25 +01:00
bors
a0485c5a90 Auto merge of #1686 - thomcc:cmpxchg_weak, r=oli-obk
Add random failures to compare_exchange_weak

In practice this is pretty useful for detecting bugs.

This fails more frequently than realistic (~~50%~~ (now 80%, controlled by a flag) of the time). I couldn't find any existing code that tries to model this (tsan, cdschecker, etc all seem to have TODOs there). Relacy models it with a 25% or 50% failure chance depending on some settings.

CC `@JCTyblaidd` who wrote the code this modifies initially, and seems interested in this subject.
2021-01-28 09:52:04 +00:00
Ralf Jung
e308eeb3f1 rustup; more slack for timing tests 2021-01-27 10:44:08 +01:00
Ralf Jung
d38e861f1e rustup; allow some lints 2021-01-26 11:43:39 +01:00
Thom Chiovoloni
d4b592ed17 Fail 80% of the time on weak cmpxchg, not 50% 2021-01-26 00:13:54 -08:00
Thom Chiovoloni
efd2d55e00 review nits 2021-01-26 00:13:54 -08:00
Thom Chiovoloni
b6eccc6482 Test that _weak atomics sometimes fail 2021-01-26 00:13:54 -08:00
Thom Chiovoloni
c678bd722e Add random failures to compare_exchange_weak 2021-01-26 00:13:54 -08:00
Ralf Jung
3990debf82 rustup; test swap of element with itself 2021-01-22 09:22:53 +01:00
Ralf Jung
4a035103dc rustup; make tests pass again 2021-01-15 16:41:14 +01:00
Ralf Jung
82c6c77b9a test Weak into_raw/from_raw on dangling ptrs 2020-12-31 13:11:34 +01:00
Ralf Jung
7e198147df panicing now works with -Zmiri-track-raw-pointers 2020-12-31 00:17:08 +01:00
Ralf Jung
3d151c8b62 leak checker: also test AtomicPtr stored via 'swap' 2020-12-21 11:36:39 +01:00
JCTyBlaidd
3df67141e6 Disable tests in windows 2020-12-13 11:04:58 +00:00
JCTyBlaidd
fbe7fbb890 Add concurrent caller location test 2020-12-13 11:04:58 +00:00
JCTyBlaidd
c45b1b16be More tests, fix issue 1643 and detect races with allocation. 2020-12-13 11:04:58 +00:00
Ralf Jung
27a518e166 enable track-raw-ptr tests on Windows 2020-12-11 11:28:33 +01:00
Ralf Jung
2f0d7d38b4 rustup; test AtomicPtr leak checker 2020-12-10 00:09:52 +01:00
bors
a2fa80d277 Auto merge of #1641 - JCTyblaidd:update_release_sequences, r=RalfJung
Weaken release sequences to match the C++20 memory model

See [Weaken Release Sequences](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0982r1.html), since the exception for relaxed writes on the same thread as a release write not blocking release sequences was removed in the C++20 memory model compared to the C11 memory model the paper was based on. The implementation can be updated and simplified to match this.  [Rust is currently specified to use the C++20 memory model](https://doc.rust-lang.org/std/sync/atomic/index.html).
2020-12-06 19:12:16 +00:00
JCTyBlaidd
4cf614ef33 Update release sequence handling to C++20 semantics. 2020-12-06 16:58:32 +00:00
Mara Bos
de5b26d7f0 Use new std::alloc::Allocator interface.
This was changed in core.
2020-12-05 00:13:33 +01:00
bors
d473242ecd Auto merge of #1617 - JCTyblaidd:data_race_detector, r=RalfJung
Add simple data-race detector

Partially fixes data-race detection, see #1372, based on Dynamic Race Detection for C++11

- This does not explore weak memory behaviour, only exploring one sequentially consistent ordering.
- Data-race detection is only enabled after the first thread is created, so should have minimal overhead for non-concurrent execution.
- ~~Does not attempt to re-use thread id's so creating and joining threads lots of time in an execution will result in the vector clocks growing in size and slowing down program execution~~ It does now
2020-11-29 18:44:28 +00:00
JCTyBlaidd
55fc552d99 Apply review changes, incrementing the clocks twice is an unnecessary hold-over from earlier versions so fixed. 2020-11-27 19:26:06 +00:00
JCTyBlaidd
3268f56a97 Fix review changes 2020-11-22 17:28:12 +00:00
Ralf Jung
7a2c2f8dde rustup; test sorting for provenance-correctness 2020-11-22 18:08:57 +01:00
est31
4de113acba Normalize column numbers 2020-11-19 09:21:11 +01:00