Skip to content

Seg fault when using AsyncContext::builder()Β #479

@robalar

Description

@robalar

Hi there, thanks for all your work on this crate.

Came across an interesting one when trying to create a minimal working context to evaluate some code. Creating a AsyncContext with just the Eval intrinsic causes a seg fault when evaluating some code.

For example this seg faults:

let runtime = AsyncRuntime::new().unwrap();
let context = AsyncContext::builder()
    .with::<intrinsic::Eval>()
    .build_async(&runtime)
    .await
    .unwrap();

context
    .with(|ctx| {
        let code = "let x = 42;".to_string();
        ctx.eval::<rquickjs::Value, _>(code.as_bytes()).unwrap();
    })
    .await;

where as this does not:

let runtime = AsyncRuntime::new().unwrap();
let context = AsyncContext::builder()
    .with::<intrinsic::Eval>()
    .build_async(&runtime)
    .await
    .unwrap();

context
    .with(|ctx| {
        let code = "1 + 1;".to_string(); // <--- different code snippet
        ctx.eval::<rquickjs::Value, _>(code.as_bytes()).unwrap();
    })
    .await;

and this also does not seg fault:

let runtime = AsyncRuntime::new().unwrap();
let context = AsyncContext::full(&runtime).await.unwrap();  // <-- full context

context
    .with(|ctx| {
        let code = "let x = 42;".to_string();  // <--- same code snippet as seg fault
        ctx.eval::<rquickjs::Value, _>(code.as_bytes()).unwrap();
    })
    .await;

I have a full MRE repo here with all these examples.

EDIT: this is on arm64-apple-darwin24.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug:1-repro-availableBug reproduction is availablekind:bugAn unexpected problem or behaviourtopic:interfaceRelated to safe abstractions over the primitivestopic:runtimeRelated to the runtime objecttopic:safetyViolations of safety causing undefined behaviours

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions