Commit Graph

461 Commits

Author SHA1 Message Date
JCTyblaidd
c4ccd0b6a1 Fix nits
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2020-12-13 11:04:58 +00:00
JCTyBlaidd
f4bcef1113 Increase sleep times for the scheduler 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
7bbd6bca77 rustup 2020-12-10 19:53:45 +01:00
JCTyBlaidd
a6f377e48e Fix typo 2020-12-06 17:11:24 +00:00
JCTyBlaidd
4cf614ef33 Update release sequence handling to C++20 semantics. 2020-12-06 16:58:32 +00: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
db718d72ae remove some unnecessary feature flags 2020-11-10 16:51:07 +01:00
JCTyBlaidd
2a40d9b7a0 More aggressive vector index re-use, and added some tests. 2020-11-06 17:29:54 +00:00
Ralf Jung
f31f00d5af rustup 2020-11-05 17:09:44 +01:00
JCTyBlaidd
95c99b2044 Detect races between atomic and non-atomic accesses of a variable,
previously only data races between two non-atomic accesses were
 detected.
2020-11-04 21:35:48 +00:00
JCTyBlaidd
fe2e857cc3 Add newlines at end of file + use replace.
add dangling thread variant of one of the benchmarks
2020-11-02 13:08:09 +00:00
JCTyBlaidd
2e75de5ac9 Mark all new tests as disabled on windows 2020-11-02 12:40:12 +00:00
JCTyBlaidd
ed32b260f9 Add tests, and fix bug in atomic RMW relaxed stores 2020-11-02 02:57:06 +00:00
Ralf Jung
bf54607ba0 test raw pointer tracking; we cannot track raw pointers on Windows 2020-10-28 13:54:50 +01:00
Aaron Hill
be51e6bd07
Add an fn_ptr field to MiriFrame
The `backtrace-rs` crate can use this to implement
`Frame::symbol_address`, which is used to skip frames
above the call to `Backtrace::capture` on the stack.

The function pointer will not be useable for comparison purposes if the
function is generic, as CTFE creates a new function pointer for each
cast of a (monomorphized) generic function. However, this already
affects code running under Miri, and isn't a problem for `backtrace-rs`
(which only casts a non-generic function).

I've added logic to allow `MiriFrame` to have either 4 or 5 fields - if
a 5th field is present, we write the function pointer to it.
2020-10-10 13:07:57 -04:00
Ralf Jung
b350c80a31 add backtics back in isolation error message 2020-10-03 15:25:30 +02:00
Mara Bos
5880e7d809 Update expected error messages in tests. 2020-10-03 12:00:29 +02:00
Aaron Hill
e1bce19ca9
Make some error messages lowercase 2020-09-28 13:44:45 -04:00
Aaron Hill
b89f6561e5
Move things around 2020-09-28 13:44:45 -04:00
Aaron Hill
ef43c5a614
Use a 'flags' parameter instead of 'version' 2020-09-28 13:44:45 -04:00
Aaron Hill
22f1eb01ee
Add API for capturing backtrace
This PR adds two new Miri-defined extern functions:
`miri_get_backtrace` and `miri_resolve_frame`, which are documented in
the README. Together, they allow obtaining a backtrace for the currently
executing program.

I've added a test showing how these APIs are used. I've also prepared a
companion PR `backtrace-rs`, which will allow
`backtrace::Backtrace::new()` to work automatically under Miri.

Once these two PRs are merged, we will be able to print backtraces from
the normal Rust panic hook (since libstd is now using backtrace-rs).

A few notes:
* Resolving the backtrace frames is *very* slow - you can actually see
  each line being printed out one at a time. Some local testing showed
  that this is not (primrary) caused by resolving a `Span` - it seems
  to be just Miri being slow.
* For the first time, we now interact directly with a user-defined
  struct (instead of just executing the user-provided MIR that
  manipulates the struct). To allow for future changes, I've added
  a 'version' parameter (currently required to be 0). This should allow
  us to change the `MiriFrame` struct should the need ever arise.
* I used the approach suggested by @oli-obk - a returned backtrace
  pointer consists of a base function allocation, with the 'offset'
  used to encode the `Span.lo`. This allows losslessly reconstructing
  the location information in `miri_resolve_frame`.
* There are a few quirks on the `backtrace-rs` side:
  * `backtrace-rs` calls `getcwd()` by default to try to simplify
    the filename. This results in an isolation error by default,
    which could be annoying when printing a backtrace from libstd.
  * `backtrace-rs` tries to remove 'internal' frames (everything between
     the call to `Backtrace::new()` and the internal API call made by
     backtrace-rs) by comparing the returned frame pointer value to
     a Rust function pointer. This doesn't work due to the way we
     construct the frame pointers passed to the caller. We could
     attempt to support this kind of comparison, or just add a
    `#[cfg(miri)]` and ignore the frames ourselves.
2020-09-28 13:44:45 -04:00
Ralf Jung
67c5067a2f rustup; fix tests 2020-09-24 09:19:03 +02:00
Ralf Jung
4b5e78052a rustup; support panic=abort on Windows 2020-09-20 15:55:36 +02:00
Ralf Jung
08e076c658 account for mir-opts masking more errors 2020-09-20 12:18:02 +02:00
Ralf Jung
83a339e5a9 rustup; make sure the iterator moves even with smarter optimizations 2020-09-20 10:26:22 +02:00
Ralf Jung
32cdb7131b support panic=abort 2020-09-18 13:10:18 +02:00
Samrat Man Singh
563fb8e43d Implement dup and close for stdin/stdout/stderr
Support F_DUPFD on stdin/stdout/stderr

Enable `close`-ing stdin/stdout/stderr

For `dup`, check if FD is `File` first

If not, clone the appropriate standard IO stream

Merge POSIX `close` and `dup` tests into same module

Also, add assertion that `write` on a closed FD returns an error.

Add `dup` as FileDescriptor trait fn

Also:
- Fix `close` so it drops `self` instead of reference to it
- Remove FD clamping in insert_fd_with_min_fd, since FDs 0-2 can be
closed

Fix fs_libc tests

Make error message when closing stdin/out/err more specific

Return io::Result from `FileDescriptor::dup`

Change error message when closing stdin/out/err

Refactor `FileDescriptor::dup` impl for `FileHandle`

Remove empty line
2020-09-09 23:26:33 +05:30
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
210f18d6c7 work around rustc optimizations becoming too smart 2020-09-07 10:24:38 +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
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
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
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
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
Justus K
d23e245f38
Move no_main test to compile-fail 2020-07-09 17:21:09 +02:00