Commit Graph

1346 Commits

Author SHA1 Message Date
Ralf Jung
3fdbc0fd3f fix referenced issue 2020-09-07 13:10:31 +02:00
Ralf Jung
3ba1035d27 use standard black_box function 2020-09-07 11:29:47 +02:00
Ralf Jung
029c851d7c another optimization work-around 2020-09-07 11:23:09 +02:00
Ralf Jung
088af66f85
better optimization suppression
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2020-09-07 11:16:16 +02:00
Ralf Jung
d9bc19a7b0 test opt-level 2 2020-09-07 10:43:49 +02:00
Ralf Jung
210f18d6c7 work around rustc optimizations becoming too smart 2020-09-07 10:24:38 +02:00
David Cook
417ac2939a Implement libc::nanosleep shim 2020-09-06 18:07:17 -05:00
David Cook
6d323e1032 Refactor timespec parsing, improve error handling 2020-09-06 18:07:14 -05:00
bors
c28a8eeb74 Auto merge of #1532 - divergentdave:thread-panic-payload, r=RalfJung
Move panic payload state from Machine to Thread

This PR moves the panic payload storage from the `Machine` state to per-thread state. Prior to this change, if one thread panicked while another was still unwinding, Miri would fail with `thread 'rustc' panicked at 'the panic runtime should avoid double-panics', src/shims/panic.rs:51:9`. I ran into this issue while prototyping a round-robin scheduler, but it's also reachable with the current scheduler and contrived programs that use blocking API calls to cause thread switching during unwinding. I wrote a test case along those lines for this change.
2020-09-03 10:09:34 +00:00
David Cook
7a2c6812b9 Per-thread errno storage 2020-09-02 20:57:20 -05:00
Ralf Jung
3466462306 rustup, fix test 2020-09-01 10:55:09 +02:00
David Cook
da2f268443 Review comments 2020-08-31 19:32:14 -05:00
David Cook
3ba7f46058 Move panic payload state from Machine to Thread 2020-08-29 21:38:37 -05:00
Ralf Jung
39e6baeb91 rustup 2020-08-27 09:27:58 +02:00
Ralf Jung
2f9de18f88 rustup; account for ptr_offset_from stabilization 2020-08-24 10:06:44 +02:00
Ralf Jung
df9b2127ce fix a test for big-endian targets 2020-08-22 18:07:43 +02:00
Ralf Jung
237bea2c17 avoid promotion in alignment test to get different alignment on each try 2020-08-20 10:14:13 +02:00
Ralf Jung
d5b15297ac forgot to add alignment test loop in one test 2020-08-18 10:19:29 +02:00
Ralf Jung
5b1bc4ba94 make another test more robust against random alignment 2020-08-17 18:22:46 +02:00
Ralf Jung
0913653e06 make sure we test panic of interpreter-impelemted align_offset 2020-08-16 18:31:48 +02:00
Ralf Jung
d4e5943259 use real align_offset unless we symbolic alignment check is enabled 2020-08-16 18:26:04 +02:00
Ralf Jung
cb985670c1 make alignment check integer-based by default, and add an option to make it symbolic 2020-08-16 17:08:38 +02:00
Ralf Jung
80929e17ae add test for unused ill-formed constant
also use better span in TopFrameInfo
2020-08-13 08:33:36 +02:00
Ralf Jung
da2260db44 make sure opening a file fails with isolation enabled 2020-08-10 10:10:08 +02:00
Ralf Jung
5657f08bea fs: move isolation handling to inside trait 2020-08-08 15:24:30 +02:00
bors
cf633d0e89 Auto merge of #1498 - RalfJung:rustup, r=RalfJung
rustup

The allocator API changed *again*, adjust our test.
2020-08-05 11:39:07 +00:00
Ralf Jung
422113a491 rustup 2020-08-05 13:38:15 +02:00
Samrat Man Singh
bdef57ea45 Flush to stdout from FileDescriptor::write for Stdout
Also, remove unnecessary `-Zmiri-disable-isolation` in test
2020-08-04 20:40:48 +05:30
Samrat Man Singh
bea7113eb8 Add impl FileDescriptor for stdin, stdout, stderr
- Use `FileDescriptor::read` for stdin reads
- Use `FileDescriptor::write` for stdout/err writes
- Handle stdout/err reads in `FileDescriptor::read`
2020-08-04 01:14:52 +05:30
Ralf Jung
5d22145069 test unwinding past topmost frame of a stack 2020-08-01 14:20:05 +02:00
Ralf Jung
35309a200b rustup; fix linked_list test 2020-08-01 14:18:52 +02:00
Ralf Jung
729ccbc65e test track_caller on trait objects 2020-07-31 18:30:07 +02:00
Ralf Jung
ee39ac9840 rustup for new folder layout 2020-07-29 14:27:14 +02:00
Ralf Jung
cae90b6d29 rustup and test fixes 2020-07-27 23:40:27 +02:00
Ralf Jung
c77540ce13 deallocate thread-local statics when the thread dies 2020-07-27 23:32:15 +02:00
Ralf Jung
2a42f8e93c fix and test order of TLS dtors and thread joining 2020-07-27 23:32:15 +02:00
Ralf Jung
390899e8b9 test referencing unsupported extern static 2020-07-27 23:32:15 +02:00
Ralf Jung
bc0569253f enable leak check tests on Windows 2020-07-23 15:56:38 +02:00
Ralf Jung
f68bba9906 test casting a dangling ptr back from an int 2020-07-11 20:56:47 +02:00
Justus K
d23e245f38
Move no_main test to compile-fail 2020-07-09 17:21:09 +02:00
Justus K
c93fc933bd
Add ui test for early exiting if no main 2020-07-09 14:08:45 +02:00
Ralf Jung
6c2521f54f adjust error messages 2020-07-07 22:48:51 +02:00
Ralf Jung
28b44d970c test validation of uninit memory (used to ICE) 2020-07-07 22:48:51 +02:00
Ralf Jung
6ca67a346b rustup 2020-07-02 10:48:01 +02:00
Ralf Jung
fcdacce4b1 fix some ignore-windows comments 2020-06-28 20:40:20 +02:00
Ralf Jung
3a5bcb97ed move rwlock dequeuing to shared code, and use that code for Windows rwlocks 2020-06-28 11:28:46 +02:00
Ralf Jung
e54619b5e1 with this, we support panics on Windows 2020-06-27 14:43:37 +02:00
Ralf Jung
dca00ab85e introduce platform-specific module hierarchy for dlsym (similar to foreign_items) 2020-06-27 14:36:05 +02:00
bors
bde2eb4a44 Auto merge of #1460 - RalfJung:modules, r=RalfJung
Re-organize platform-specific shims

Move platform-specific code to `shims::{posix::{linux, macos}, windows}`. Also make it private in these modules to ensure we are reasonably structured.
2020-06-27 11:27:36 +00:00
Ralf Jung
395f5d40dc Rename shims::{sync -> posic_sync} and move sync_singlethread test to other sync test 2020-06-27 12:37:12 +02:00
Ralf Jung
b46f946c81 supply our own implementation of the CTFE pointer comparison intrinsics 2020-06-27 11:57:43 +02:00
Ralf Jung
3ea8c5fa33 bump Rust 2020-06-26 20:36:08 +02:00
Ralf Jung
2e5a0dc172 add a miscompilation test 2020-06-22 11:32:01 +02:00
Ralf Jung
8d1d572472 unaligned-raw-deref is always UB 2020-06-20 14:34:57 +02:00
Ralf Jung
03fe3772a8 make sure the raw_ptr macros also avoid UB 2020-06-20 14:31:47 +02:00
Ralf Jung
a29f86b512 make sure '&raw *' on a dangling raw ptr is UB 2020-06-20 14:28:55 +02:00
Ralf Jung
2940da9d1f bump Rust 2020-06-20 11:48:42 +02:00
bors
ffd03b3caa Auto merge of #1418 - divergentdave:file-sync, r=RalfJung
Add file sync shims

This PR adds shim implementations for these related file syncing functions.
* `fsync`, for POSIX targets, backed by `File::sync_all()`
* `fdatasync`, for POSIX targets, backed by `File::sync_data()`
* `fcntl` with command `F_FULLFSYNC`, for macOS targets, backed by `File::sync_all()`
* `sync_file_range`, for Linux targets, backed by `File::sync_data()`
2020-06-09 08:48:40 +00:00
David Cook
e352d4fbb7 Finish fixing Windows host support 2020-06-06 16:54:13 +00:00
Ralf Jung
dcb2b30982 rustup, and adjust timing tests 2020-06-03 09:40:21 +02:00
Ralf Jung
7d406b152a test WTF8 encoding corner cases 2020-06-01 01:12:31 +02:00
bors
4fd0aa316e Auto merge of #1441 - RalfJung:sync-cleanup, r=RalfJung
Synchronization primitive cleanup

Make some methods infallible, move a bit more work into the platform-independent `sync.rs`, and fix a bug in rwlock unlocking.
2020-05-31 09:10:19 +00:00
Ralf Jung
3032224d19 rustup, adjust error message 2020-05-31 10:30:25 +02:00
Ralf Jung
acb3ec0866 test and fix for rwlock unlock bug 2020-05-30 22:48:43 +02:00
Ralf Jung
c77e9022d5 rustup (and account for stabilization) 2020-05-30 09:23:25 +02:00
Ralf Jung
ac454a2485 cargo-miri: allow overwriting miri command, and make that consistent with compiletest 2020-05-28 08:53:44 +02:00
David Cook
3252082474 Fix test on Windows hosts
FlushFileBuffers requires that a file be opened for writing
2020-05-25 13:20:29 -05:00
David Cook
7ba8bbc49f Update comments 2020-05-25 07:32:56 -05:00
Vytautas Astrauskas
34ddd775e8 Increase the elapsed time window. 2020-05-25 08:07:07 +02:00
Vytautas Astrauskas
90590a399d Small fixes. 2020-05-25 00:02:54 +02:00
Vytautas Astrauskas
6ff0af3adf Fix #1419. 2020-05-25 00:02:54 +02:00
Vytautas Astrauskas
bd97074517 Small changes. 2020-05-25 00:02:54 +02:00
Vytautas Astrauskas
babedc938e Rewrite notify all test. 2020-05-25 00:02:54 +02:00
Vytautas Astrauskas
8b5a9836be Small changes. 2020-05-25 00:02:54 +02:00
Vytautas Astrauskas
fdfd56b75b Small changes. 2020-05-25 00:02:54 +02:00
Vytautas Astrauskas
86eb262e8a Cleanup Condvar tests. 2020-05-25 00:02:54 +02:00
Vytautas Astrauskas
4a303b1309 Add a timeout test for conditional variables. 2020-05-25 00:02:54 +02:00
Vytautas Astrauskas
6e774dec86 Move all run-pass synchronization primitive tests to sync.rs. 2020-05-25 00:02:54 +02:00
Vytautas Astrauskas
679245769b Implement support for synchronization primitives. 2020-05-25 00:02:54 +02:00
Ralf Jung
e6ced2f9c4 add interesting unsizing test 2020-05-24 12:03:06 +02:00
bors
70d5caf17e Auto merge of #1429 - RalfJung:discriminant_value, r=RalfJung
test discriminant_value intrinsic

Make sure this works for all types, not just enums/generators.
2020-05-23 14:31:37 +00:00
Ralf Jung
404c37999b test discriminant_value intrinsic 2020-05-23 16:30:50 +02:00
David Cook
87a846f2d6 Update to match rustc changes 2020-05-22 17:03:25 +02:00
Ralf Jung
cc1a2119f6 adjust for changed allocation strategy 2020-05-20 00:00:35 +02:00
David Cook
0b060c7364 Review comments 2020-05-19 08:57:31 -05:00
David Cook
87c4694448 Add file sync shims
Adds implementations for fsync, fdatasync, and sync_file_range
2020-05-17 22:10:40 -05:00
Ralf Jung
791ec8fef7 fmt 2020-05-11 10:54:21 +02:00
Ralf Jung
88fc42bbc8 compiletest: no need to call rustc here 2020-05-11 10:52:44 +02:00
Oliver Scherer
3fdab9c446 Update to rustc changes 2020-05-10 10:14:03 +02:00
Ralf Jung
b4ad90669b rustup 2020-05-07 23:59:26 +02:00
Ralf Jung
fb3a067ac6 rustup; fix error messages 2020-05-07 08:38:59 +02:00
Ralf Jung
da6846c8a9 copy some float cast tests from rustc 2020-05-06 22:46:42 +02:00
Chase Albert
f741f2cc71 Correct the test. 2020-05-04 23:22:00 -04:00
Chase Albert
f46d197431 Test for too many args. 2020-05-04 13:51:23 -04:00
Chase Albert
46aaab30fe Add a test for check_arg_count. 2020-05-04 13:51:23 -04:00
Ralf Jung
ec95ed4556 rename single-threaded sync test 2020-05-04 09:45:15 +02:00
Ralf Jung
f2f4e6fc65 also test panic from thread with name 2020-05-03 12:51:48 +02:00
Ralf Jung
c26fb591fa also test std::hint::spin_loop 2020-05-03 12:47:23 +02:00
Ralf Jung
2b591b849f test panics in threads 2020-05-03 12:43:38 +02:00
Ralf Jung
ff1f0b06cc explain what happens in a test 2020-05-03 12:43:38 +02:00
Ralf Jung
dbd6403955 rustup for fixed error messages 2020-05-02 02:13:48 +02:00
Ralf Jung
393165f859 rustup; fix for changed error messages 2020-05-01 14:43:59 +02:00
Ralf Jung
1a704a517a rustup, adjust error messages 2020-05-01 10:29:39 +02:00
Vytautas Astrauskas
48da0cf489 Fix prctl SET_NAME and GET_NAME behaviour. 2020-04-30 08:35:59 -07:00
Vytautas Astrauskas
3b5854191c Fix MacOS and Windows builds. 2020-04-27 15:21:01 -07:00
Vytautas Astrauskas
331dbd1469 Add a test for joining in a destructor. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
39efdf31cf Move prctl test to the same file as other libc tests. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
60cd8aa4b0 Delete a duplicate test. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
ff5e35b90a Added a test that joining main is UB. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
feb188360e Unify TLS dtors; move stepping outside. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
8240ed26a9 Change the test not to rely on internals. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
90e9a87fa7 Add an explanatory comment to the test. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
cc9248a7c8 Ignore prctl test on MacOS because it does not support it. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
eaa63266d8 Make multiple threads to try to join a thread while it is still running. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
8a7dbde372 Check prctl argument types and fix the test. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
40e50bf58b Clarify test comments. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
e7b82fde4a Fix the test annotation. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
e7c2694b8b Make the main thread detached. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
9a01c3fa3e Clarify comments about TLS destructor handling in Windows, add a test for TLS destructors. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
5b55e0706c Add more concurrency tests. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
80459bbf77 Improve concurrency tests. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
75e6549c11 Improve prctl, add a test. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
421be273cc Add concurrency tests. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
d9ec0f2b36 Add a missing newline in the test. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
325c31e578 Address some of the reviewers comments. 2020-04-27 14:26:36 -07:00
Vytautas Astrauskas
1c8a59c691 Rebase on PR 1157. 2020-04-27 14:23:32 -07:00
Vytautas Astrauskas
b04bf8a514 Rustfmt the test. 2020-04-27 14:23:32 -07:00
Vytautas Astrauskas
aef4c95599 Fix the problem of sending pointed to thread local statics. Add a regression test. 2020-04-27 14:23:32 -07:00
Vytautas Astrauskas
92946b5a9c Add a test for thread locals. 2020-04-27 14:23:32 -07:00
Vytautas Astrauskas
82f17ab917 Implement basic support for concurrency (Linux only). 2020-04-27 14:23:32 -07:00
bors
e06df3a881 Auto merge of #1373 - RalfJung:test-rename, r=RalfJung
rename tests: undefined -> uninit
2020-04-27 10:54:57 +00:00
bors
4556daadc2 Auto merge of #1370 - samrat:add-scalar-size-test, r=RalfJung
Add test to verify that argument size mismatch throws UB

Also, bump up `rust-version`

Closes #1355
2020-04-27 10:33:29 +00:00
Ralf Jung
a5ddaa07eb rename tests: undefined -> uninit 2020-04-27 12:32:03 +02:00
Samrat Man Singh
73f258c451 Replace error-pattern with annotation; remove unreachable line 2020-04-27 15:34:42 +05:30
bors
da940eb91f Auto merge of #1354 - divergentdave:dump-alloc-on-undef-read, r=RalfJung
Print hex dump of alloc on reading undef bytes

Here's a small addition I made locally to the UB diagnostics, in case you're interested in it. This PR calls `dump_alloc()` on the relevant allocation if Miri fails on UB due to reading undefined bytes. This came in handy when diagnosing such an issue in a large program using unsafe Rust, in part because it wasn't deterministic enough to use `-Zmiri-track-alloc-id=`. If you'd like to put this behind another -Z flag, let me know.
2020-04-27 09:33:30 +00:00
Samrat Man Singh
ae9796b9d8 Fix shim_arg_size test for 32-bit machines 2020-04-27 10:00:35 +05:30
Samrat Man Singh
da86c81e39 Add test to verify arg size mismatch throws UB
Also: bump up `rust-version`
2020-04-27 09:37:31 +05:30
Ralf Jung
c46668c556 fix exit code on rustc errors 2020-04-25 11:12:50 +02:00
David Cook
7f92eab3c4 Add test to exercise InvalidUndefBytes 2020-04-23 20:00:25 -05:00
Ralf Jung
a5eaa5703c test suite: rely on CARGO_BIN_EXE_ env vars to find Miri binary 2020-04-23 19:20:09 +02:00
bors
26baf87e43 Auto merge of #1348 - RalfJung:raw-addr-of-align, r=RalfJung
Stacked Borrows: alignment does not matter

Fixes https://github.com/rust-lang/miri/issues/1339
Requires https://github.com/rust-lang/rust/pull/71280
2020-04-22 21:44:14 +00:00
Ralf Jung
270adbc7c6 Stacked Borrows: alignment does not matter 2020-04-22 23:32:19 +02:00
David Cook
54897f66f8 Implement ftruncate64/ftruncate for File::set_len 2020-04-21 21:17:54 -05:00
bors
8d9db57a0d Auto merge of #1335 - vakaras:add-threads-noop, r=RalfJung
Move the stack to the evaluator. (no-op PR for 70598)

The changes to Miri to make it to compile with Rustc PR https://github.com/rust-lang/rust/pull/70598.
2020-04-20 08:39:29 +00:00
Ralf Jung
73772fede6 adjust for Weak::as_raw -> as_ptr rename 2020-04-20 10:04:17 +02:00
bors
763782aa08 Auto merge of #1342 - divergentdave:pause-instruction, r=RalfJung
Handle std::sync::atomic::spin_loop_hint()

This PR adds support for `std::sync::atomic::spin_loop_hint()` by implementing the `llvm.x86.sse2.pause` intrinsic when the target is x86-based. It appears this is the first LLVM intrinsic in foreign_items, so I added a couple match blocks to handle it or fall through to the different OS-specific methods. I added a basic smoke test to `tests/run-pass/sync.rs`. I came across this by way of `crossbeam::utils::Backoff::spin()`, FWIW.
2020-04-19 14:53:02 +00:00
Ralf Jung
70c828b761 test some more extreme cast cases 2020-04-19 09:34:54 +02:00
Ralf Jung
fbf47d1784 note source of test values 2020-04-19 09:21:00 +02:00
David Cook
7b69a6271e Add support for std:🧵:yield_now 2020-04-18 19:31:02 -05:00
Ralf Jung
699685c07c rename test_cast -> test_both_cast to make purpose clearer 2020-04-18 13:07:50 +02:00