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

Segmentation fault with Deno Test #79

Open
zifeo opened this issue Jun 27, 2022 · 4 comments
Open

Segmentation fault with Deno Test #79

zifeo opened this issue Jun 27, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@zifeo
Copy link
Contributor

zifeo commented Jun 27, 2022

I felt on case looking close what is described upstream in rust-lang/rust#88737. What debugging steps could be made in order to isolate further the issue (e.g. Deno and/or Rust and/or deeper)?

@bartlomieju
Copy link
Member

Please provide a reproduction and output from your terminal, otherwise we're guessing in the blind.

@littledivy littledivy added the bug Something isn't working label Jun 27, 2022
@zifeo
Copy link
Contributor Author

zifeo commented Jun 27, 2022

@bartlomieju That was painful to derive but here we go. Can you try on your end?

// src/lib.rs
use deno_bindgen::deno_bindgen;
use tokio::runtime::Runtime;

#[deno_bindgen]
fn ping() {}

#[deno_bindgen(non_blocking)]
fn start() {
    let rt = Runtime::new().unwrap();
    rt.block_on(F::new());
}

pub struct F {}

impl F {
    pub async fn new() {
        ()
    }
}
# Cargo.toml
[package]
name = "native"
version = "0.1.0"
edition = "2021"

[lib]
name = "native"
crate-type = ["cdylib"]

[dependencies]
deno_bindgen = "0.5.1"
tokio = { version = "1.19.2", features = ["full"] }
// a_test.ts
import * as native from "./bindings/bindings.ts";

Deno.test("a", async () => {
  await native.start();
})
// b_test.ts
import * as native from "./bindings/bindings.ts";

Deno.test("B", async () => {
    await native.ping();
})
# develop
cargo clean
deno_bindgen

deno test --unstable --allow-all a_test.ts 
> Check file:///home/zifeo/repro/a_test.ts
> running 1 test from ./a_test.ts
> a ... ok (6ms)
> 
> ok | 1 passed | 0 failed (55ms)

deno test --unstable --allow-all b_test.ts
> Check file:///home/zifeo/repro/b_test.ts
> running 1 test from ./b_test.ts
> B ... ok (4ms)
> 
> ok | 1 passed | 0 failed (41ms)

deno test --unstable --allow-all b_test.ts a_test.ts
> Check file:///home/zifeo/repro/b_test.ts
> Check file:///home/zifeo/repro/a_test.ts
> running 1 test from ./b_test.ts
> B ... ok (3ms)
> running 1 test from ./a_test.ts
> a ... ok (6ms)
> 
> ok | 2 passed | 0 failed (147ms)

deno test --unstable --allow-all a_test.ts b_test.ts 
> Check file:///home/zifeo/repro/a_test.ts
> Check file:///home/zifeo/repro/b_test.ts
> running 1 test from ./a_test.ts
> a ... ok (6ms)
> 'deno test --unstable --allow-...' terminated by signal SIGSEGV (Address boundary error)

# production
cargo clean
deno_bindgen --release

deno test --unstable --allow-all a_test.ts b_test.ts
> Check file:///home/zifeo/repro/a_test.ts
> Check file:///home/zifeo/repro/b_test.ts
> running 1 test from ./a_test.ts
> a ... ok (5ms)
> running 1 test from ./b_test.ts
> B ... ok (4ms)
> 
> ok | 2 passed | 0 failed (57ms)

@bartlomieju
Copy link
Member

@littledivy can you take a look?

@zifeo
Copy link
Contributor Author

zifeo commented Jul 17, 2022

@littledivy @bartlomieju Let me know if you need something else, this is definitely a blocker for the FFI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants