Commit Graph

318 Commits

Author SHA1 Message Date
Ralf Jung
9af03bf342 add -Zmiri-strict-provenance 2022-04-01 14:10:24 -04:00
bors
57786678d4 Auto merge of #1975 - DrMeepster:backtrace_fix, r=RalfJung
Make backtraces work with #[global_allocator]

Currently, backtraces break when the global allocator is overridden because the allocator will attempt to deallocate memory allocated directly by Miri.

~~This PR fixes that by using a new memory kind and providing a function to deallocate it. We can't call the custom allocator to allocate because it's not possible to call a function in the middle of a shim.~~

This PR fixes that by adding a new version of the backtrace API accessible by setting `flags` to 1. Existing code still functions.

backtrace-rs PR: rust-lang/backtrace-rs#462

Fixes https://github.com/rust-lang/miri/issues/1996
2022-03-20 02:37:09 +00:00
DrMeepster
2c670b10df add new version of backtrace api using flags=1 2022-03-19 18:14:11 -07:00
Ben Kimock
65125df1cd Consider the cargo workspace when checking if a frame is local 2022-03-18 16:28:13 -04:00
bors
a12a48bf72 Auto merge of #2018 - RalfJung:term, r=oli-obk
exclude TERM env var by default

Fixes https://github.com/rust-lang/miri/issues/1702

r? `@oli-obk`
2022-03-12 19:12:53 +00:00
Ralf Jung
3c5cb89f63 exclude TERM by default 2022-03-12 10:14:07 -05:00
Ralf Jung
9a6450af95 also accept odd number of hex digits; add README section on randomized alignment testing 2022-03-12 10:09:15 -05:00
Ralf Jung
c03575275a update recommended CI snippet, add GHA example 2022-03-07 12:03:51 -05:00
Ralf Jung
3adc203c1c add flag to forward specific env vars (while isolation remains enabled) 2022-03-05 11:14:37 -05:00
Ben Kimock
0bd83245ed rkyv deallocation alignment issue 2022-03-03 13:10:05 -05:00
Ben Kimock
a20d1f1889 Add crossbeam-epoch and integer-encoding to the trophy case 2022-02-22 21:09:30 -05:00
Ralf Jung
a21c98a896 another for the trophy case 2022-02-20 21:41:37 -05:00
Ralf Jung
e51810df2c add and document MIRI_LIB_SRC env var to set the source from which Miri builds the standard library 2021-12-23 16:04:09 +01:00
Ralf Jung
db74c1c030 readme: be more explicit about the toolchain 2021-12-19 17:46:17 +01:00
Ralf Jung
d8bee92aee rename track-raw-pointers flag to tag-raw-pointers 2021-11-13 15:48:27 -05:00
Noah Lev
1659ef4206 Add docs for -Zmiri-check-number-validity 2021-11-10 11:36:42 -08:00
Martin Habovštiak
782085adcd
Remove vague statement from README
Addresses https://github.com/rust-lang/miri/pull/1898#discussion_r727274293
2021-10-12 18:46:23 +02:00
Martin Habovštiak
31ed3a7120
Typo fixes
Co-authored-by: Ralf Jung <post@ralfj.de>
2021-10-12 11:09:43 +02:00
Martin Habovštiak
0309de73dc
Document threading support a bit more
This adds a few known limitations around threading to the README and suggests the users to look into GitHub issues to learn more.
2021-10-09 22:19:14 +02:00
Ralf Jung
71efd950d1 also ignore 'thread leaks' with -Zmiri-ignore-leaks 2021-07-25 14:21:06 +02:00
bors
83dd2d7b1f Auto merge of #1830 - RalfJung:readme, r=RalfJung
tweak isolation-error message in README
2021-06-09 19:12:17 +00:00
Ralf Jung
87f2073c80 tweak isolation-error message in README 2021-06-09 21:09:17 +02: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
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
Kitsu
c6bcb4d3c0 Specify miri toolchain for CI example 2021-06-09 10:48:43 +03: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
ddc2ee9db6
Move -Zmiri-disable-abi-check in README 2021-05-31 11:15:31 +08:00
hyd-dev
71f4140550
Add -Zmiri-disable-abi-check 2021-05-31 11:14:23 +08:00
Aaron Hill
16f469280e
Address review comments 2021-05-29 17:10:54 -05:00
Aaron Hill
7e9da8d30e
Add measureme integration for profiling the interpreted program
This PR uses the `measureme` crate to profile the call stack of the
program being interpreted by Miri. This is accomplished by starting a
measureme 'event' when we enter a function call, and ending the event
when we exit the call. The `measureme` tooling can be used to produce a
call stack from the generated profile data.

Limitations:
* We currently record every single entry/exit. This might generate very
  large profile outputs for programs with a large number of function
  calls. In follow-up work, we might want to explore sampling (e.g. only
  recording every N function calls).
* This does not integrate very well with Miri's concurrency support.
  Each event we record starts when we push a frame, and ends when we pop
  a frame. As a result, switching between virtual threads will cause
  events from different threads to be interleaved. Additionally, the
  recorded for a particular frame will include all of the work Miri does
  before that frame completes, including executing another thread.

The `measureme` integration is off by default, and must be enabled via
`-Zmiri-measureme=<output_name>`
2021-05-29 17:01:52 -05:00
scottmcm
97b2824ada
Add copy_within to the SB trophy case 2021-05-27 00:14:13 +00:00
Diana
67ec0a5ce3 Fix dead self-link 2021-05-03 22:52:09 -04:00
Ralf Jung
6834944fd3 fix MIRI_BE_RUSTC value during sysroot build 2021-04-18 12:29:31 +02:00
Ralf Jung
87882f2c6a add the bad doctests we found to the trophy case 2021-04-10 12:33:18 +02:00
bors
b9b2af9729 Auto merge of #1764 - RalfJung:readme, r=RalfJung
fix typo in README

"you program" → "your program"
2021-04-09 09:29:48 +00:00
Ralf Jung
0a7a41f6ad fix typo in README 2021-04-09 11:24:33 +02:00
hyd-dev
3dff1d4fcd
Don't use MIRI_DEFAULT_ARGS to compile host crates 2021-04-09 00:57:59 +08:00
Ralf Jung
a760aab828 mention 'cargo miri test filter' in README 2021-04-07 10:09:42 +02:00
Tristan Dannenberg
4fccde54ac make cargo-miri run doc-tests 2021-04-05 11:48:17 +02:00
Johnathan Van Why
12005612ab
README.md: Apply RalfJung's suggestion
`-Zmiri-track-raw-pointers` isn't *much* more restrictive than normal Stacked Borrows.

Co-authored-by: Ralf Jung <post@ralfj.de>
2021-03-24 16:20:54 -07:00
Johnathan Van Why
03be4138ed -Zmiri-track-raw-pointers doc correction: it is not strictly more restrictive than Stacked Borrows.
This change is based on the following comment:
https://github.com/rust-lang/miri/pull/1748#issuecomment-803279473
2021-03-22 15:35:18 -07:00
Johnathan Van Why
263be25484 Improvements to the README item on -Zmiri-track-raw-pointers.
1. The double quotes around <untagged> are changed to backspaces, so <untagged>
   will render correctly in markdown.
2. Clarify that -Zmiri-track-raw-pointers will never accept code that Miri
   would not have accepted without -Zmiri-track-raw-pointers.
2021-03-19 09:27:36 -07:00
Oli Scherer
397443093d
Update README.md 2021-01-30 20:06:05 +01:00
Oli Scherer
bd04091a16
Update README.md
Co-authored-by: Ralf Jung <post@ralfj.de>
2021-01-30 20:05:21 +01:00
Oli Scherer
35ece43ef7
Document -Zmiri-compare-exchange-weak-failure-rate 2021-01-28 10:58:33 +01:00
Ralf Jung
056016571f add -Zmiri-disable-data-race-detector to readme 2021-01-24 15:58:37 +01:00
Ralf Jung
4a13f24839 expand README 2021-01-23 16:54:00 +01:00
Ralf Jung
e204c0fbab link to our shiny new Zulip stream 2020-12-21 14:39:18 +01:00
Ralf Jung
27a518e166 enable track-raw-ptr tests on Windows 2020-12-11 11:28:33 +01:00
Jonah Williams
789c8a006b
Fix README.md typo "extend" -> "extent"
Just something I noticed while reading
2020-12-06 17:54:59 -08:00
Ralf Jung
7fb012fdb2 readme: mention data races, and mention cross-interpretation already in the intro 2020-12-05 12:14:52 +01:00
Ralf Jung
d697de7538 update README 2020-11-29 20:54:56 +01:00
Ralf Jung
7eaba6684c fix trophy case URL 2020-10-31 16:28:56 +01:00
Camelid
02af2a38ac
Fix link in README 2020-10-29 16:14:54 -07:00
bors
c3a84c1ca8 Auto merge of #1606 - RalfJung:trophy, r=oli-obk
update trophy case
2020-10-28 13:40:51 +00:00
bors
83f7657ed0 Auto merge of #1603 - RalfJung:track-raw, r=oli-obk
add an option to track raw pointer tags in Stacked Borrows

Also make error messages more informative by printing the affected memory location
2020-10-28 13:19:25 +00:00
Ralf Jung
2589b48251 update trophy case 2020-10-28 14:05:37 +01:00
Ralf Jung
70af7aed88 expand flag docs 2020-10-28 13:03:46 +01:00
Ralf Jung
00c4869d56 remove outdated CI badges 2020-10-28 12:57:41 +01:00
Ralf Jung
194451345d add an option to track raw pointer tags in Stacked Borrows 2020-10-28 12:23:35 +01:00
Camelid
8df239b020 Fix README 2020-10-23 11:53:34 -07:00
bors
158639c985 Auto merge of #1590 - RalfJung:trophy, r=RalfJung
another TiKV bug for the trophy case :)

Cc `@brson` thanks for the ping!
2020-10-22 07:46:10 +00:00
Ralf Jung
0835ac6ec3 another TiKV bug for the trophy case :) 2020-10-21 12:50:45 +02:00
Aaron Hill
05bb560de2
Enable backtrace feature in the generated Xargo.toml
This allows the normal std panic hook to print a backtrace if
`RUST_BACKTRACE=1` and `-Z miri-disable-isolation` are set
2020-10-20 18:27:55 -04:00
bors
8beccc4bef Auto merge of #1581 - RalfJung:readme, r=RalfJung
README: make our cross-interpretation feature stand out more

This is a great feature, let's hope more people notice it :)
2020-10-11 22:56:39 +00:00
bors
73d5c42076 Auto merge of #1580 - Aaron1011:feature/backtrace-fn-ptr, r=RalfJung
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-11 22:34:57 +00:00
Ralf Jung
3bdf2bccae
Improve wording
Co-authored-by: Aaron Hill <aa1ronham@gmail.com>
2020-10-12 00:15:01 +02:00
bors
c467345bb0 Auto merge of #1571 - lzutao:actions, r=RalfJung
Adding a working github actions template

Complete adding github actions whose dummy template added in #1563 .

But it will need https://github.com/rust-lang/rust-central-station/pull/939 merged first
to be able to gate bors on Actions CI checks.
2020-10-11 22:07:25 +00:00
Lzu Tao
6acde94931 Add a working github actions template 2020-10-11 18:32:12 +07:00
Ralf Jung
71e0e59b63 README: make our cross-interpretation feature stand out more 2020-10-11 10:49:59 +02: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
Yonggang Luo
e6665109e0
Update README.md
Note however that
[leak checking is currently disabled on Windows targets](https://github.com/rust-lang/miri/issues/1302).

Windows issue are fixed
2020-10-09 13:16:03 +08:00
Ralf Jung
b1837d0bc9
fix typo 2020-09-28 13:44:46 -04:00
Aaron Hill
5571bcfc4f
Require #[repr(C)] on MiriFrame 2020-09-28 13:44:46 -04:00
Aaron Hill
11e2dbd51c
Update README 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
5652052e23 list two more aliasing problems we found in BTreeMap and VecDeque 2020-09-19 11:39:13 +02:00
Ralf Jung
32cdb7131b support panic=abort 2020-09-18 13:10:18 +02:00
Ralf Jung
b244a2ddaa make sure subcrate tests have the right cwd 2020-09-17 17:33:47 +02:00
Ralf Jung
9a9988a4b0 update docs, and also use MIRIFLAGS for the test suite 2020-09-17 17:29:19 +02:00
Ralf Jung
4608341ca0 add encoding_rs OOB arithmetic 2020-08-27 08:37:11 +02:00
Ralf Jung
3b7f36ef8d emphasize that some flags are unsound to use 2020-08-22 14:31:46 +02:00
Ralf Jung
f691e573b2 tweak alignment check docs 2020-08-17 11:51:18 +02:00
Ralf Jung
5a579f281d document -Zmiri-symbolic-alignment-check 2020-08-16 17:12:32 +02:00
Ralf Jung
06f8bf6afa document Miri extern functions 2020-07-23 17:14:25 +02:00
Ralf Jung
6dbfb2d9de make cfg(miri) greppable 2020-07-15 10:09:28 +02:00
Ralf Jung
c379793cde add option to track call IDs 2020-07-02 10:33:54 +02:00
Youngsuk Kim
ea4a5587ca
Add a case to list of 'StackedBorrows violations'
A small fix was made to libstd in rust-lang/rust#70479 (back in March).
(Miri reported UB due to Stacked Borrows violation - [link to Miri error log](https://github.com/rust-lang/miri/pull/1225#discussion_r397830221))

Thank you for reviewing 👍
2020-06-08 17:30:43 -04:00
Ralf Jung
67ad304140 update unsupported example in README (now that threading is supported on some platforms) 2020-05-30 22:50:49 +02:00
Ralf Jung
e22baedb1f add test suite filter example to README and 'cargo miri --help' 2020-05-17 10:12:17 +02:00
Ralf Jung
938fe00f02 fix some comments, and run_compiler return type 2020-05-11 00:09:46 +02:00
Ralf Jung
12114c5137 fix dead link in README 2020-05-10 18:52:21 +02:00
Ralf Jung
e65d87b110
Typo 2020-05-09 14:08:58 +02:00
Ralf Jung
ba801a45db make Miri work in rustc bootstrap stage 0 2020-05-09 13:19:23 +02:00
Ralf Jung
132feb88db
adjust wording 2020-05-07 11:21:31 +02:00
Brian Anderson
356848c9b9 Add two more TiKV bugs to trophy case 2020-05-07 02:42:12 +00:00
bors
6ded8aadab Auto merge of #1386 - RalfJung:trophy, r=RalfJung
trophy case: consistent wording (X doing Y)
2020-05-02 09:41:31 +00:00
Ralf Jung
df4623e5d8 trophy case: consistent wording (X doing Y) 2020-05-02 11:08:20 +02:00
Ralf Jung
15c299e657
Adjust wording 2020-05-02 11:04:45 +02:00