Open sigmaSd opened 1 year ago
it boils down to mio trying to use an unspported syscall, here is a minimum reproduction
main.rs
use mio::{Events, Poll};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut poll = Poll::new()?;
let mut events = Events::with_capacity(1024);
poll.poll(&mut events, None)?;
Ok(())
}
Cargo.toml
[package]
name = "lab"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
mio = { version = "0.8.8", features = ["os-poll"] }
[profile.release]
strip = true
panics with Function not implemented
when run inside x86_64 proot
Wow, thank you for the reproduction code.
I debugged a bit and it seems like epoll_wait implementation is the problem, it shows up like this in strace
epoll_wait(3, [{events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, {events=0, data={u32=0, u64=0}}, ...], 1024, -1) = 232
which seems very suspicious
it seems like its receiving events
instead of a pointer to events
Actually I'm not sure about my epoll_wait assumption maybe its just how strace formatting.
But I did follow the code with gdb and that seems the last syscall it uses in mio
turns out its indeed epoll_wait
that's failing https://github.com/tokio-rs/mio/blob/2856112500284f83dcdfa6de20dda2516caa59fb/src/sys/unix/selector/epoll.rs#L97
If I change that to use epoll_pwait
instead the minimal example does work
I tried to reproduce with a simple c program
#include <sys/epoll.h>
int main() {
int epoll_fd = epoll_create1(0);
struct epoll_event events[10];
epoll_wait(epoll_fd, events, 10, -1);
}
but this works and strace shows its making a call to epoll_pwait
instead epoll_wait
So it seems like proot make this translation somewhere ? not sure why the same thing doesn't happen with rust
somehow this bug doesn't happen on proot aarch64 , deno seems to work there https://github.com/denoland/deno/issues/4862#issuecomment-1049502951
I'm using termux on waydroid to test, it just occured to me that maybe its waydroid (or the image it uses) issue
Or a waydroid/proot interaction, compiling the minimal example does work on waydroid termux without proot (compiled to android-x86-64)
I tried with a different x86-64 android emulator (https://appetize.io) and it errors the same way
Using deno with patched mio that uses pwait indeed works correctly
Expected Behavior
deno works with no error on x86_64 linux via proot
Actual Behavior
deno panics inside tokio
Steps to Reproduce the Problem
Specifications
Linux waydroid 6.2.1-PRoot-Distro #1 ZEN SMP PREEMPT_DYNAMIC Thu, 27 Jul 2023 22:02:02 +0000 x86_64 GNU/Linux
Command Output
I'm assuming that there is a syscall that tokio is using that it isn't handled, strace doesn't show anything suspicious
The motivation is I want to use deno on termux on waydroid, the easiest way seemed to use proot