From a37cfed062bd4106fb1462a0a1e13010307bd262 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 19 Nov 2020 09:21:03 +0100 Subject: [PATCH 1/4] rustup --- rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-version b/rust-version index 3b96c994a78..5d44fe9e4b8 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -12f0dba618e761c987142474435dff95ab177f3c +bf469eb6c20ccea05400a1942c70343f36705e1c From 4de113acba482ecee67a2098e9e1ba6068304ccc Mon Sep 17 00:00:00 2001 From: est31 Date: Sun, 15 Nov 2020 05:01:10 +0100 Subject: [PATCH 2/4] Normalize column numbers --- tests/run-pass/backtrace-std.rs | 2 +- tests/run-pass/backtrace-std.stderr | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/run-pass/backtrace-std.rs b/tests/run-pass/backtrace-std.rs index 7a793e092a8..9b61aabab3b 100644 --- a/tests/run-pass/backtrace-std.rs +++ b/tests/run-pass/backtrace-std.rs @@ -1,5 +1,5 @@ // normalize-stderr-test "at .*/(rust[^/]*|checkout)/library/" -> "at RUSTLIB/" -// normalize-stderr-test "RUSTLIB/(.*):\d+"-> "RUSTLIB/$1:LL" +// normalize-stderr-test "RUSTLIB/([^:]*):\d+:\d+"-> "RUSTLIB/$1:LL:CC" // normalize-stderr-test "::<.*>" -> "" // compile-flags: -Zmiri-disable-isolation diff --git a/tests/run-pass/backtrace-std.stderr b/tests/run-pass/backtrace-std.stderr index 45c46acc331..09f035b9724 100644 --- a/tests/run-pass/backtrace-std.stderr +++ b/tests/run-pass/backtrace-std.stderr @@ -1,28 +1,28 @@ 0: func_d - at $DIR/backtrace-std.rs:18 + at $DIR/backtrace-std.rs:18:45 1: func_c - at $DIR/backtrace-std.rs:17 + at $DIR/backtrace-std.rs:17:45 2: func_b - at $DIR/backtrace-std.rs:11 + at $DIR/backtrace-std.rs:11:48 3: func_a - at $DIR/backtrace-std.rs:10 + at $DIR/backtrace-std.rs:10:45 4: main - at $DIR/backtrace-std.rs:21 + at $DIR/backtrace-std.rs:21:19 5: >::call_once - shim(fn()) - at RUSTLIB/core/src/ops/function.rs:LL + at RUSTLIB/core/src/ops/function.rs:LL:CC 6: std::sys_common::backtrace::__rust_begin_short_backtrace - at RUSTLIB/std/src/sys_common/backtrace.rs:LL + at RUSTLIB/std/src/sys_common/backtrace.rs:LL:CC 7: std::rt::lang_start::{closure#0} - at RUSTLIB/std/src/rt.rs:LL + at RUSTLIB/std/src/rt.rs:LL:CC 8: std::ops::function::impls::call_once - at RUSTLIB/core/src/ops/function.rs:LL + at RUSTLIB/core/src/ops/function.rs:LL:CC 9: std::panicking::r#try::do_call - at RUSTLIB/std/src/panicking.rs:LL + at RUSTLIB/std/src/panicking.rs:LL:CC 10: std::panicking::r#try - at RUSTLIB/std/src/panicking.rs:LL + at RUSTLIB/std/src/panicking.rs:LL:CC 11: std::panic::catch_unwind - at RUSTLIB/std/src/panic.rs:LL + at RUSTLIB/std/src/panic.rs:LL:CC 12: std::rt::lang_start_internal - at RUSTLIB/std/src/rt.rs:LL + at RUSTLIB/std/src/rt.rs:LL:CC 13: std::rt::lang_start - at RUSTLIB/std/src/rt.rs:LL + at RUSTLIB/std/src/rt.rs:LL:CC From cdb7adb4b32168b79a44f332ceace67aee727c42 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 18 Nov 2020 23:15:32 +0100 Subject: [PATCH 3/4] Make weak syscalls in std work. std now looks up `getrandom` and `statx` with `dlsym` before attempting to use `syscall(SYS_.., ..)`. It also now passes all arguments as a machine-sized word, instead of their original types. --- src/shims/posix/linux/dlsym.rs | 2 ++ src/shims/posix/linux/foreign_items.rs | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/shims/posix/linux/dlsym.rs b/src/shims/posix/linux/dlsym.rs index ca5cf3ffe8f..2685a93726d 100644 --- a/src/shims/posix/linux/dlsym.rs +++ b/src/shims/posix/linux/dlsym.rs @@ -12,6 +12,8 @@ impl Dlsym { pub fn from_str(name: &str) -> InterpResult<'static, Option> { Ok(match &*name { "__pthread_get_minstack" => None, + "getrandom" => None, // std falls back to syscall(SYS_getrandom, ...) when this is NULL. + "statx" => None, // std falls back to syscall(SYS_statx, ...) when this is NULL. _ => throw_unsup_format!("unsupported Linux dlsym: {}", name), }) } diff --git a/src/shims/posix/linux/foreign_items.rs b/src/shims/posix/linux/foreign_items.rs index 04efa79b9d9..21d765621f7 100644 --- a/src/shims/posix/linux/foreign_items.rs +++ b/src/shims/posix/linux/foreign_items.rs @@ -208,7 +208,11 @@ fn getrandom<'tcx>( // The only supported flags are GRND_RANDOM and GRND_NONBLOCK, // neither of which have any effect on our current PRNG. - this.read_scalar(flags)?.to_i32()?; + let flags = this.read_scalar(flags)?; + // Either `i32` or `isize` is fine. + if flags.to_machine_isize(this).is_err() { + flags.to_i32()?; + } this.gen_random(ptr, len)?; this.write_scalar(Scalar::from_machine_usize(len, this), dest)?; From 517728bf97b5be2f609a9c539c7fdade2c601555 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 19 Nov 2020 09:36:06 +0100 Subject: [PATCH 4/4] avoid fallback logic (and we do not need the flag value currently anyway) --- src/shims/posix/linux/foreign_items.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/shims/posix/linux/foreign_items.rs b/src/shims/posix/linux/foreign_items.rs index 21d765621f7..23dc02a6aff 100644 --- a/src/shims/posix/linux/foreign_items.rs +++ b/src/shims/posix/linux/foreign_items.rs @@ -208,11 +208,9 @@ fn getrandom<'tcx>( // The only supported flags are GRND_RANDOM and GRND_NONBLOCK, // neither of which have any effect on our current PRNG. - let flags = this.read_scalar(flags)?; - // Either `i32` or `isize` is fine. - if flags.to_machine_isize(this).is_err() { - flags.to_i32()?; - } + let _flags = this.read_scalar(flags)?; + // FIXME: Check that this is an integer type of the right size. + // Currently, some callers pass i32 and some usize, is that even allowed? this.gen_random(ptr, len)?; this.write_scalar(Scalar::from_machine_usize(len, this), dest)?;