Commit Graph

75 Commits

Author SHA1 Message Date
Ralf Jung
d09db1660b fix and slightly improve data race reports 2022-07-01 20:13:44 -04:00
Ralf Jung
dfdedae840 avoid copying thread manager state in data race detector 2022-07-01 17:07:29 -04:00
Ralf Jung
f992099820 fix ICE when const refers to extern static 2022-06-21 21:03:40 -07:00
Ralf Jung
b64c9a0a83 make scheduler preemptive, with configurable preemption rate 2022-06-06 20:16:02 -04:00
Andy Wang
8739e45bef
Move data_race and weak_memory into a submodule 2022-06-06 19:15:53 +01:00
Ralf Jung
47745380cd make Miri's scheduler proper round-robin 2022-06-05 14:22:00 -04:00
Ben Kimock
5861d137b2 Set the current span (somewhat) lazily 2022-04-30 10:25:52 -04:00
David Tolnay
d35c82f79f
Resolve clippy::useless_conversion
error: useless conversion to the same type: `rustc_const_eval::interpret::Pointer<std::option::Option<machine::Tag>>`
       --> src/helpers.rs:668:36
        |
    668 |                 this.get_ptr_alloc(ptr.offset(len, this)?.into(), size1, Align::ONE)?.unwrap(); // not a ZST, so we will get a result
        |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `ptr.offset(len, this)?`
        |
        = note: `-D clippy::useless-conversion` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

    error: useless conversion to the same type: `rustc_const_eval::interpret::Pointer<std::option::Option<machine::Tag>>`
       --> src/helpers.rs:678:29
        |
    678 |         this.read_bytes_ptr(ptr.into(), len)
        |                             ^^^^^^^^^^ help: consider removing `.into()`: `ptr`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

    error: useless conversion to the same type: `rustc_const_eval::interpret::Pointer<std::option::Option<machine::Tag>>`
       --> src/helpers.rs:690:44
        |
    690 |             let alloc = this.get_ptr_alloc(ptr.into(), size2, align2)?.unwrap(); // not a ZST, so we will get a result
        |                                            ^^^^^^^^^^ help: consider removing `.into()`: `ptr`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

    error: useless conversion to the same type: `rustc_const_eval::interpret::OpTy<machine::Tag>`
       --> src/shims/intrinsics.rs:778:42
        |
    778 |                         .read_immediate(&this.operand_index(index, i)?.into())?
        |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `this.operand_index(index, i)?`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

    error: useless conversion to the same type: `u32`
        --> src/shims/posix/fs.rs:1171:26
         |
    1171 |             builder.mode(mode.into());
         |                          ^^^^^^^^^^^ help: consider removing `.into()`: `mode`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

    error: useless conversion to the same type: `std::ffi::OsString`
      --> src/shims/env.rs:67:53
       |
    67 |                     ecx.machine.env_vars.map.insert(OsString::from(name), var_ptr);
       |                                                     ^^^^^^^^^^^^^^^^^^^^ help: consider removing `OsString::from()`: `name`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

    error: useless conversion to the same type: `rustc_const_eval::interpret::Scalar<machine::Tag>`
       --> src/shims/tls.rs:102:44
        |
    102 |                 Ok(value.unwrap_or_else(|| Scalar::null_ptr(cx).into()))
        |                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `Scalar::null_ptr(cx)`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

    error: useless conversion to the same type: `u32`
      --> src/thread.rs:73:26
       |
    73 |         Scalar::from_u32(u32::try_from(self.0).unwrap())
       |                          ^^^^^^^^^^^^^^^^^^^^^
       |
       = help: consider removing `u32::try_from()`
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
2022-04-29 16:02:11 -07:00
David Tolnay
2f32221fe4
Resolve clippy::redundant_field_names
error: redundant field names in struct initialization
       --> src/helpers.rs:199:34
        |
    199 |         let place = mir::Place { local: local, projection: List::empty() };
        |                                  ^^^^^^^^^^^^ help: replace it with: `local`
        |
        = note: `-D clippy::redundant-field-names` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

    error: redundant field names in struct initialization
       --> src/thread.rs:238:13
        |
    238 |             threads: threads,
        |             ^^^^^^^^^^^^^^^^ help: replace it with: `threads`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
2022-04-29 15:57:16 -07:00
David Tolnay
48f4f2734d
Resolve clippy::redundant_closure
error: redundant closure
       --> src/data_race.rs:787:18
        |
    787 |             .map(|idx| VectorIdx::new(idx))
        |                  ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `VectorIdx::new`
        |
        = note: `-D clippy::redundant-closure` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure

    error: redundant closure
      --> src/thread.rs:61:31
       |
    61 |         u32::try_from(id).map(|id_u32| Self(id_u32))
       |                               ^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `Self`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
2022-04-29 15:56:27 -07:00
David Tolnay
519755a823
Resolve clippy::needless_return
error: unneeded `return` statement
       --> src/helpers.rs:734:13
        |
    734 |             return Ok(());
        |             ^^^^^^^^^^^^^^ help: remove `return`: `Ok(())`
        |
        = note: `-D clippy::needless-return` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return

    error: unneeded `return` statement
       --> src/range_map.rs:113:9
        |
    113 |         return true;
        |         ^^^^^^^^^^^^ help: remove `return`: `true`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return

    error: unneeded `return` statement
       --> src/shims/posix/fs.rs:648:25
        |
    648 |                 None => return this.handle_not_found(),
        |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove `return`: `this.handle_not_found()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return

    error: unneeded `return` statement
      --> src/shims/panic.rs:62:9
       |
    62 |         return Ok(());
       |         ^^^^^^^^^^^^^^ help: remove `return`: `Ok(())`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return

    error: unneeded `return` statement
       --> src/shims/panic.rs:115:9
        |
    115 |         return Ok(());
        |         ^^^^^^^^^^^^^^ help: remove `return`: `Ok(())`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return

    error: unneeded `return` statement
       --> src/thread.rs:477:9
        |
    477 |         return free_tls_statics;
        |         ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove `return`: `free_tls_statics`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return

    error: unneeded `return` statement
       --> src/thread.rs:459:17
        |
    459 |                 return false;
        |                 ^^^^^^^^^^^^^ help: remove `return`: `false`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
2022-04-29 15:53:48 -07:00
David Tolnay
1fa63f1e9b
Resolve clippy::extra_unused_lifetimes
error: this lifetime isn't used in the function definition
      --> src/helpers.rs:46:20
       |
    46 | fn try_resolve_did<'mir, 'tcx>(tcx: TyCtxt<'tcx>, path: &[&str]) -> Option<DefId> {
       |                    ^^^^
       |
       = note: `-D clippy::extra-unused-lifetimes` implied by `-D clippy::all`
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes

    error: this lifetime isn't used in the function definition
      --> src/shims/posix/fs.rs:49:12
       |
    49 |     fn dup<'tcx>(&mut self) -> io::Result<Box<dyn FileDescriptor>>;
       |            ^^^^
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes

    error: this lifetime isn't used in the function definition
      --> src/shims/os_str.rs:81:41
       |
    81 |         pub fn u16vec_to_osstring<'tcx, 'a>(u16_vec: Vec<u16>) -> InterpResult<'tcx, OsString> {
       |                                         ^^
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes

    error: this lifetime isn't used in the function definition
      --> src/thread.rs:72:26
       |
    72 |     pub fn to_u32_scalar<'tcx>(&self) -> Scalar<Tag> {
       |                          ^^^^
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes
2022-04-29 15:38:12 -07:00
Ralf Jung
763ff1c49f do not consider thread-local allocations read-only 2022-04-19 14:56:07 -04:00
Ralf Jung
855af088b8 remove no longer needed imports 2022-04-09 11:32:49 -04:00
Ralf Jung
6e1f3cd8ff adjust for MemoryExtra being merged into Machine 2022-04-05 11:11:53 -04:00
Ralf Jung
594a70a289 rustup 2022-03-07 09:39:32 -05:00
Ralf Jung
71efd950d1 also ignore 'thread leaks' with -Zmiri-ignore-leaks 2021-07-25 14:21:06 +02:00
Ralf Jung
a1233a721d adjust Miri to Pointer type overhaul 2021-07-16 10:10:12 +02:00
Ralf Jung
e09c571eec avoid some borrow_mut calls in data_race 2021-05-23 18:04:13 +02:00
Ralf Jung
c73f8b1097 fmt 2021-05-22 14:55:33 +02:00
Ralf Jung
1bbd6e609c get rid of Rc in data_race 2021-05-22 14:47:14 +02:00
Ralf Jung
4e231bab5e format much of Miri 2021-05-16 11:48:28 +02:00
bors
e6ffc689aa Auto merge of #1772 - RalfJung:less-timeout-checking, r=RalfJung
only check timeouts when a thread yields

Currently, we check for expired timeouts after each step of execution. That seems excessive. This changes the scheduler to only check for timeouts when the active thread cannot continue running any more.

`@vakaras` does this sound right? `pthread_cond_timedwait` anyway already yields, of course, since it blocks on getting the signal (or the timeout).
2021-04-11 14:59:27 +00:00
Vytautas Astrauskas
50f68dce21 Reference issue 1763 in the comment. 2021-04-11 13:39:03 +02:00
Ralf Jung
bda328e26a only check timeouts when a thread yields 2021-04-11 13:32:47 +02:00
Vytautas Astrauskas
72ca2a7a85 Attempt to fix #1763 by asking the scheduler to retry choosing an operation. 2021-04-10 20:23:32 +02: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
JCTyBlaidd
69fb6413dd Tidy up comments and function layout, should fix most of the review notes. 2020-11-15 18:30:26 +00:00
JCTyBlaidd
2a40d9b7a0 More aggressive vector index re-use, and added some tests. 2020-11-06 17:29:54 +00:00
JCTyBlaidd
c70bbea257 Move to use of thread termination hook for vector re-use,
convert validate atomic op to use shared reference and get_raw
 instead of get_raw_mut so it can be used for validate_atomic_load as well
2020-11-05 14:18:28 +00:00
JCTyBlaidd
9cb6b8da3f Split out vector_clock to separate file, general tidy up of some of the
code & add support for vector index re-use for multiple threads
 after termination.
2020-11-05 03:54:39 +00:00
JCTyBlaidd
89814f1b3f Initial data-race detector,
passes all current tests but additional tests are required
2020-11-02 02:57:05 +00:00
David Cook
7a2c6812b9 Per-thread errno storage 2020-09-02 20:57:20 -05: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
Oliver Scherer
94f13efefd Bump for rustc changes 2020-08-11 11:37:29 +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
7b07fc385c get_or_create_thread_local_alloc_id: share code with Memory::get_global_alloc 2020-07-27 23:32:15 +02:00
Ralf Jung
0a4e8caa8c adjust to canonical_alloc_id removal 2020-07-27 23:32:15 +02:00
Ralf Jung
545aa60195 fix typo
Co-authored-by: Oliver Scherer <github35764891676564198441@oli-obk.de>
2020-07-17 13:40:13 +02:00
Ralf Jung
d617d615e4 fix non-fatal diagnostics stacktraces 2020-07-17 12:55:45 +02: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
7589bc7ba9 sync cleanup: mark infallible ops as such; consistent combine en/dequeue with (un)block; comments 2020-05-30 22:29:27 +02:00
Vytautas Astrauskas
90590a399d Small fixes. 2020-05-25 00:02:54 +02:00
Vytautas Astrauskas
bd97074517 Small changes. 2020-05-25 00:02:54 +02:00
Vytautas Astrauskas
0838347d8f Change the scheduling to execute timeout callbacks first. 2020-05-25 00:02:54 +02:00
Vytautas Astrauskas
fdfd56b75b Small changes. 2020-05-25 00:02:54 +02:00
Vytautas Astrauskas
0bbac12751 Change how the time is handled. 2020-05-25 00:02:54 +02:00
Vytautas Astrauskas
044a068c67 Improve code readability and comments. 2020-05-25 00:02:54 +02:00