Skip to content

Commit 3ad58b1

Browse files
committed
libc_current_sigrtmax stub
1 parent fdc49aa commit 3ad58b1

File tree

4 files changed

+49
-9
lines changed

4 files changed

+49
-9
lines changed

src/shims/unix/foreign_items.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
8383
let result = this.socketpair(domain, type_, protocol, sv)?;
8484
this.write_scalar(Scalar::from_i32(result), dest)?;
8585
}
86+
"__libc_current_sigrtmax" => {
87+
// TODO this function takes `void`. does anything go in this let?
88+
let [] = this.check_shim(abi, Abi::C {unwind: false}, link_name, args)?;
89+
90+
let result = this.libc_current_sigrtmax()?;
91+
this.write_scalar(Scalar::from_i32(result), dest)?;
92+
}
8693
"close" => {
8794
let [fd] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
8895
let result = this.close(fd)?;

src/shims/unix/fs.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
793793
Ok(0)
794794
}
795795

796+
fn libc_current_sigrtmax(&mut self) -> InterpResult<'tcx, i32> {
797+
let _this = self.eval_context_mut();
798+
799+
// TODO return the correct value
800+
Ok(42)
801+
}
802+
796803
fn read(
797804
&mut self,
798805
fd: i32,

tests/fail/crates/tokio_mvp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@compile-flags: -Zmiri-disable-isolation
2-
//@error-pattern: unsupported operation: can't call foreign function: __libc_current_sigrtmax
2+
//@error-pattern: unsupported operation: cannot close epoll
33
//@normalize-stderr-test: " = note: inside .*\n" -> ""
44
//@only-target-linux: the errors differ too much between platforms
55

tests/fail/crates/tokio_mvp.stderr

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,45 @@
1-
error: unsupported operation: can't call foreign function: __libc_current_sigrtmax
2-
--> CARGO_REGISTRY/.../mod.rs:LL:CC
1+
warning: integer-to-pointer cast
2+
--> CARGO_REGISTRY/.../imp_std.rs:LL:CC
33
|
4-
LL | unsafe { __libc_current_sigrtmax() }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function: __libc_current_sigrtmax
4+
LL | let mut waiter = (queue & !STATE_MASK) as *const Waiter;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ integer-to-pointer cast
66
|
7-
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
7+
= help: This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`,
8+
= help: which means that Miri might miss pointer bugs in this program.
9+
= help: See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation.
10+
= help: To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead.
11+
= help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics.
12+
= help: Alternatively, the `-Zmiri-permissive-provenance` flag disables this warning.
813
= note: backtrace:
914
note: inside `main` at $DIR/tokio_mvp.rs:LL:CC
1015
--> $DIR/tokio_mvp.rs:LL:CC
1116
|
1217
LL | #[tokio::main]
1318
| ^^^^^^^^^^^^^^
14-
= note: this error originates in the attribute macro `tokio::main` (in Nightly builds, run with -Z macro-backtrace for more info)
19+
= note: this warning originates in the attribute macro `tokio::main` (in Nightly builds, run with -Z macro-backtrace for more info)
20+
21+
warning: integer-to-pointer cast
22+
--> CARGO_REGISTRY/.../word_lock.rs:LL:CC
23+
|
24+
LL | (self & QUEUE_MASK) as *const ThreadData
25+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ integer-to-pointer cast
26+
|
27+
note: inside `main` at $DIR/tokio_mvp.rs:LL:CC
28+
--> $DIR/tokio_mvp.rs:LL:CC
29+
|
30+
LL | #[tokio::main]
31+
| ^
32+
= note: this warning originates in the attribute macro `tokio::main` (in Nightly builds, run with -Z macro-backtrace for more info)
1533

16-
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
34+
error: unsupported operation: cannot close epoll
35+
--> CARGO_REGISTRY/.../epoll.rs:LL:CC
36+
|
37+
LL | if let Err(err) = syscall!(close(self.ep)) {
38+
| ^^^^^^^^^^^^^^^^^^^^^^^^ cannot close epoll
39+
|
40+
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
41+
= note: backtrace:
42+
= note: this error originates in the macro `syscall` (in Nightly builds, run with -Z macro-backtrace for more info)
1743

18-
error: aborting due to previous error
44+
error: aborting due to previous error; 2 warnings emitted
1945

0 commit comments

Comments
 (0)