dtolnay / dtolnay/no-panic

false positive on trivial call to libc::mmap

Open
#57 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.2k
Forks
20
PR merge metrics
No merged PRs in 30d

Description

I've made a wrapper around `libc::mmap` that does literally nothing except apply the #[no_panic] attribute, and I get the "detected panic in function `my_mmap`" error.

```
#[no_panic]
pub unsafe extern "C" fn my_mmap(
addr: *mut libc::c_void,
len: libc::size_t,
prot: libc::c_int,
flags: libc::c_int,
fd: libc::c_int,
offset: libc::off_t,
) -> *mut libc::c_void {
libc::mmap(addr, len, prot, flags, fd, offset)
}
```

If I replace `#[no_panic]` with `#[inline(never)]` and run `cargo asm`, I see the following

```
mov esi, 2097152
mov edx, 3
mov ecx, 262194
mov r8d, -1
xor r9d, r9d
jmp mmap
```

and if there's a panic in there I can't see it. Is no-panic fundamentally incompatible with libc functions?

Note: I'm building in release mode with `rustc 1.79.0-nightly`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.