Skip to content

Commit

Permalink
libc_current_sigrtmax stub
Browse files Browse the repository at this point in the history
  • Loading branch information
DebugSteven committed Sep 1, 2022
1 parent 0d14c91 commit 51dcc27
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 10 deletions.
7 changes: 7 additions & 0 deletions src/shims/unix/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
let result = this.socketpair(domain, type_, protocol, sv)?;
this.write_scalar(Scalar::from_i32(result), dest)?;
}
"__libc_current_sigrtmax" => {
// TODO this function takes `void`. does anything go in this let?
let [] = this.check_shim(abi, Abi::C {unwind: false}, link_name, args)?;

let result = this.libc_current_sigrtmax()?;
this.write_scalar(Scalar::from_i32(result), dest)?;
}
"close" => {
let [fd] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
let result = this.close(fd)?;
Expand Down
7 changes: 7 additions & 0 deletions src/shims/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
Ok(0)
}

fn libc_current_sigrtmax(&mut self) -> InterpResult<'tcx, i32> {
let _this = self.eval_context_mut();

// TODO return the correct value
Ok(42)
}

fn read(
&mut self,
fd: i32,
Expand Down
2 changes: 1 addition & 1 deletion tests/fail/crates/tokio_mvp.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@compile-flags: -Zmiri-disable-isolation
//@error-pattern: unsupported operation: can't call foreign function: __libc_current_sigrtmax
//@error-pattern: unsupported operation: cannot close epoll
//@normalize-stderr-test: " = note: inside .*\n" -> ""
//@only-target-linux: the errors differ too much between platforms

Expand Down
44 changes: 35 additions & 9 deletions tests/fail/crates/tokio_mvp.stderr
Original file line number Diff line number Diff line change
@@ -1,19 +1,45 @@
error: unsupported operation: can't call foreign function: __libc_current_sigrtmax
--> CARGO_REGISTRY/.../mod.rs:LL:CC
warning: integer-to-pointer cast
--> CARGO_REGISTRY/.../imp_std.rs:LL:CC
|
LL | unsafe { __libc_current_sigrtmax() }
| ^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function: __libc_current_sigrtmax
LL | let mut waiter = (queue & !STATE_MASK) as *const Waiter;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ integer-to-pointer cast
|
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
= note: BACKTRACE:
= help: This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`,
= help: which means that Miri might miss pointer bugs in this program.
= help: See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation.
= 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.
= help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics.
= help: Alternatively, the `-Zmiri-permissive-provenance` flag disables this warning.
= note: backtrace:
note: inside `main` at $DIR/tokio_mvp.rs:LL:CC
--> $DIR/tokio_mvp.rs:LL:CC
|
LL | #[tokio::main]
| ^^^^^^^^^^^^^^
= note: this error originates in the attribute macro `tokio::main` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this warning originates in the attribute macro `tokio::main` (in Nightly builds, run with -Z macro-backtrace for more info)

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
warning: integer-to-pointer cast
--> CARGO_REGISTRY/.../word_lock.rs:LL:CC
|
LL | (self & QUEUE_MASK) as *const ThreadData
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ integer-to-pointer cast
|
note: inside `main` at $DIR/tokio_mvp.rs:LL:CC
--> $DIR/tokio_mvp.rs:LL:CC
|
LL | #[tokio::main]
| ^
= note: this warning originates in the attribute macro `tokio::main` (in Nightly builds, run with -Z macro-backtrace for more info)

error: unsupported operation: cannot close epoll
--> CARGO_REGISTRY/.../epoll.rs:LL:CC
|
LL | if let Err(err) = syscall!(close(self.ep)) {
| ^^^^^^^^^^^^^^^^^^^^^^^^ cannot close epoll
|
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
= note: backtrace:
= note: this error originates in the macro `syscall` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error
error: aborting due to previous error; 2 warnings emitted

0 comments on commit 51dcc27

Please sign in to comment.