Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deno panic #363

Open
sigmaSd opened this issue Aug 3, 2023 · 10 comments
Open

deno panic #363

sigmaSd opened this issue Aug 3, 2023 · 10 comments

Comments

@sigmaSd
Copy link

sigmaSd commented Aug 3, 2023

Expected Behavior

deno works with no error on x86_64 linux via proot

Actual Behavior

deno panics inside tokio

Steps to Reproduce the Problem

  1. proot-distro install debian
  2. proot-distro login debian
  3. curl -fsSL https://deno.land/x/install/install.sh | sh
  4. .deno/bin/deno

Specifications

  • Proot/Care version: 5.1.0
  • Kernel version: Linux waydroid 6.2.1-PRoot-Distro #1 ZEN SMP PREEMPT_DYNAMIC Thu, 27 Jul 2023 22:02:02 +0000 x86_64 GNU/Linux
  • Host distribution: arch
  • Guest distribution: debian

Command Output

Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: linux x86_64
Version: 1.35.3
Args: [".deno/bin/deno"]

thread '<unnamed>' panicked at 'unexpected error when polling the I/O driver: Os { code: 38, kind: Unsupported, message: "Function not implemented" }', /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.28.1/src/runtime/io/mod.rs:180:23
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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

@sigmaSd
Copy link
Author

sigmaSd commented Aug 3, 2023

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

@oxr463
Copy link
Collaborator

oxr463 commented Aug 4, 2023

Wow, thank you for the reproduction code.

@sigmaSd
Copy link
Author

sigmaSd commented Aug 5, 2023

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

@sigmaSd
Copy link
Author

sigmaSd commented Aug 5, 2023

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

@sigmaSd
Copy link
Author

sigmaSd commented Aug 13, 2023

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

@sigmaSd
Copy link
Author

sigmaSd commented Aug 13, 2023

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

@sigmaSd
Copy link
Author

sigmaSd commented Aug 13, 2023

somehow this bug doesn't happen on proot aarch64 , deno seems to work there denoland/deno#4862 (comment)

@sigmaSd
Copy link
Author

sigmaSd commented Aug 13, 2023

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)

@sigmaSd
Copy link
Author

sigmaSd commented Aug 13, 2023

I tried with a different x86-64 android emulator (https://appetize.io) and it errors the same way

@sigmaSd
Copy link
Author

sigmaSd commented Aug 13, 2023

Using deno with patched mio that uses pwait indeed works correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants