Commit Graph

4709 Commits

Author SHA1 Message Date
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
bors
69d050fb6b Auto merge of #1495 - samrat:fd-trait, r=oli-obk
Add FileDescriptor trait to abstract fn's on File's and Stdin,Stdout,Stderr

Related issue: #1486

Instead of mapping FDs to `FileHandle`, map them to a `FileDescriptor` trait object. The goal is to eventually have both `FileHandle` as well as `Stdin`, `Stdout` and `Stderr` implement this trait so that syscalls involving FDs can handle both `File`s as well as the standard IO streams.

This PR adds the `FileDescriptor` trait and an `impl` for `FileHandle`. I'll open a separate PR for implementing the trait for the standard IO streams.
2020-08-03 15:50:30 +00:00
Samrat Man Singh
79e066fc95 Remove unnecessary clone() on writable 2020-08-03 20:39:09 +05:30
bors
2d2820dc77 Auto merge of #1496 - RalfJung:rustup, r=RalfJung
rustup; inner_deref has been stabilized

miri and cargo-miri now use no nightly features (except for miri's using `rustc_private`, of course) :D
2020-08-03 12:25:11 +00:00
Ralf Jung
cda255cfb4 rustup; inner_deref has been stabilized 2020-08-03 14:20:46 +02:00
Samrat Man Singh
3386f12eca Wrap io::Result from FileDescriptor::{read,write,seek} in InterpResult
The outer InterpResult will be used to indicate that a fn is not
implemented for a struct(eg. `write` for Stdin).

The inner io::Result is just the result from the read/write/seek.
2020-08-03 11:01:42 +05:30
Samrat Man Singh
e3956f4200 Add FileDescriptor trait to abstract fn's on File's and Std{in,out,err} 2020-08-01 20:53:50 +05:30
bors
8a28eaa3fc Auto merge of #1494 - RalfJung:stack-unwind-top, r=RalfJung
test unwinding past topmost frame of a stack

This tests https://github.com/rust-lang/rust/pull/74984
2020-08-01 12:20:45 +00:00
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
bors
7b970ef05e Auto merge of #1493 - RalfJung:track-test, r=RalfJung
test track_caller on trait objects

Adds a Miri-side test for https://github.com/rust-lang/rust/issues/74764.
2020-07-31 17:25:34 +00:00
Ralf Jung
729ccbc65e test track_caller on trait objects 2020-07-31 18:30:07 +02:00
bors
55bdb31746 Auto merge of #1492 - RalfJung:rustup, r=RalfJung
Rustup

Adjusting for @oli-obk' log changes.

While at it I also removed the `*_of_val` intrinsics that got moved to rustc (Cc @ecstatic-morse).
2020-07-30 16:32:53 +00:00
Ralf Jung
2dfde5b696 remove upstreamed intrinsic impls 2020-07-30 18:31:40 +02:00
Ralf Jung
d340933112 rustup 2020-07-30 18:31:19 +02:00
bors
720c2bf8f8 Auto merge of #1491 - RalfJung:xargo-check, r=RalfJung
only check-build the dummy xargo project

No reason to actually emit any object code.
This helps with some strange ICEs when testing Miri in the rustc workspace.
2020-07-29 16:24:43 +00:00
Ralf Jung
797436cefb only check-build the dummy xargo project 2020-07-29 18:21:32 +02:00
bors
abe55c2b5b Auto merge of #1490 - RalfJung:rustup, r=RalfJung
rustup for new folder layout

Fixes the fallout from https://github.com/rust-lang/rust/pull/73265.

Blocked on a xargo release with https://github.com/japaric/xargo/pull/301.
2020-07-29 12:27:45 +00:00
Ralf Jung
ee39ac9840 rustup for new folder layout 2020-07-29 14:27:14 +02:00
bors
79cd5a8d4a Auto merge of #1489 - RalfJung:tls-alloc-ids, r=oli-obk
Adjust for new rustc alloc ID handling and deallocate thread-local statics

Miri side of https://github.com/rust-lang/rust/pull/74775.

Fixes https://github.com/rust-lang/miri/issues/1369
Fixes https://github.com/rust-lang/miri/issues/1488
2020-07-27 22:00:15 +00:00
Ralf Jung
cae90b6d29 rustup and test fixes 2020-07-27 23:40:27 +02:00
Ralf Jung
bec7aab7fd Typos
Co-authored-by: Oliver Scherer <github35764891676564198441@oli-obk.de>
2020-07-27 23:32:15 +02:00
Ralf Jung
6fbaa72642 fix diagnostics printing when triggered during TLS dtor scheduling 2020-07-27 23:32:15 +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
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
bors
345b033c3f Auto merge of #1487 - pnadon:miri-rename-undef-uninit, r=RalfJung
Miri rename undef uninit

The changes made here are related to [issue #71193 on Rust](https://github.com/rust-lang/rust/issues/71193), and the pull request [74664 on Rust](https://github.com/rust-lang/rust/pull/74664).

1. renamed `ScalarMaybeUninit::not_undef` to `check_init`
2. renamed `Immediate::to_scalar_or_undef` to `Immediate::to_scalar_or_uninit`
2020-07-27 21:31:51 +00:00
Philippe Nadon
6dd700fd17 Changed not_undef to check_init in foreign_items.rs
Due to changes from upstream, a commit using not_undef was inserted, which had to be updated to use check_init.

related issue #71193
2020-07-27 13:07:25 -06:00
Phil Nadon
6282e92774 Updated Rust version to latest master
Updated Rust version since the latest version contains changes which allow this version of Miri to build.
2020-07-26 16:05:56 -06:00
Philippe Nadon
21268157ff renamed Immediate::to_scalar_or_undef
to Immediate::to_scalar_or_uninit

in src/shims/intrinsics.rs

related issue #71193
2020-07-26 16:05:20 -06:00
Philippe Nadon
5161ba346c renamed ScalarMaybeUninit::not_undef to check_init
Related to PR https://github.com/rust-lang/rust/pull/74664
2020-07-26 16:05:20 -06:00
bors
91b58c93c5 Auto merge of #1485 - RalfJung:miri-extern-fn, r=oli-obk
Miri: use extern fn to expose interpreter operations to program; fix leak checker on Windows

This is the Miri side of https://github.com/rust-lang/rust/pull/74681.

Fixes https://github.com/rust-lang/miri/issues/1302
Fixes https://github.com/rust-lang/miri/issues/1318
2020-07-25 08:02:54 +00:00
Ralf Jung
c641fbde02 update rust-version 2020-07-25 10:02:25 +02:00
Ralf Jung
06f8bf6afa document Miri extern functions 2020-07-23 17:14:25 +02:00
Ralf Jung
bc0569253f enable leak check tests on Windows 2020-07-23 15:56:38 +02:00
Ralf Jung
fef5fa2ae1 add a Miri extern fn to mark an allocation as being a static root for leak checking 2020-07-23 15:47:33 +02:00
Ralf Jung
4033358956 make miri_start_panic intrinsic an FFI function 2020-07-23 15:20:36 +02:00
bors
592b140880 Auto merge of #1482 - canova:remote-unreachable, r=RalfJung
Remove unreachable intrinsic

This is now supported by the interpreter with https://github.com/rust-lang/rust/pull/74459. We can remove this intrinsic implementation here.
This is covered by this test: https://github.com/rust-lang/miri/blob/master/tests/compile-fail/unreachable.rs

I guess we need to wait until the rust-lang/rust PR merges into nightly, and then we can update `rust-version` hash in the PR, right?

r? @oli-obk
2020-07-23 09:14:08 +00:00
bors
67e7eb4b9c Auto merge of #1484 - RalfJung:rustup, r=RalfJung
rustup

Following https://github.com/rust-lang/rust/pull/69749 I added some `ty::ParamEnv::reveal_all()` even though @eddyb advised me in the past to avoid those.
2020-07-23 08:41:34 +00:00
Ralf Jung
7d6aec6887 rustup 2020-07-23 10:40:13 +02:00
bors
c44f1ae485 Auto merge of #1483 - RalfJung:fs-errno, r=RalfJung
set errno on stdout write failure
2020-07-18 15:59:19 +00:00
Ralf Jung
cded9b7142 set errno on stdout write failure 2020-07-18 17:58:21 +02:00
bors
b021209b0e Auto merge of #1436 - samrat:support-stdin-read, r=RalfJung
Handle `read`s on STDIN

Closes #1434
2020-07-18 14:56:38 +00:00
Nazım Can Altınova
d1aee6965b Remove unreachable intrinsic 2020-07-18 12:48:26 +02:00
Samrat Man Singh
f4d1841811 Remove unnecessary cast 2020-07-18 10:45:06 +05:30
Samrat Man Singh
4c1beb2e45 Ensure buffer for reading from Stdin is smaller than machine usize
Also, set appropriate error code on failure
2020-07-17 20:18:07 +05:30
bors
515287f114 Auto merge of #1480 - RalfJung:diagnostic-stacktrace-fix, r=oli-obk
fix non-fatal diagnostics stacktraces

Our non-fatal diagnostics are printed *after* completing the step that triggered them, which means the span and stacktrace used for them is that of the *next* MIR statement being executed. That's quite bad, obviously, as pointing to where in the source something happens is their entire point.

Here's an example:
```rust
use std::ptr;

static mut PTR: *mut u8 = ptr::null_mut();

fn get_ptr() -> *const u8 { unsafe { PTR }}

fn cause_ub() { unsafe {
    let _x = &*get_ptr();
} }

fn main() { unsafe {
   let mut l = 0;
   PTR = &mut l;
   let r = &mut *PTR;
   cause_ub();
   let _x = *r;
} }
```
This example is UB; if you track the pointer tag that is given in the final error, it points to the entire body of `cause_ub` as a span, instead of the `&*get_ptr();`.

I am not sure what the best way is to fix this. The cleanest way would be to capture a stack trace before the step and use it in case of a diagnostic, but that seems silly perf-wise. So instead I went with reconstructing the old stacktrace by going back one step in the MIR. This is however not possible if we were executing a `Terminator`... I think those cannot cause diagnostics but still, this is not great.

Any ideas?
r? @oli-obk
2020-07-17 11:40:40 +00:00