ITADN

[Bug] interrupt handler causes an assetion failure

#663OpenUrsDeSwardt 创建于 2026-04-07
kind:bugbug:2-confirmedtopic:context
U
UrsDeSwardtcommented
## The problem I'm trying to implement a basic timeout for script execution and I'm getting this fatal error caused by the interrupt handler. ```text error executing job: Error: interrupted at resolve (native) at example (eval_script:4:27) Assertion failed: (p->ref_count > 0), function gc_decref_child, file quickjs.c, line 6183. ``` At work, we've seen other lines in `quickjs.c` also caused by the interrupt handler. - `Assertion failed: (p->ref_count > 0), function gc_decref_child, file quickjs.c, line 6063.` - `Assertion failed: (p->ref_count > 0), function gc_decref_child, file quickjs.c, line 6898.` ## Reproducible example Here is a minimal reproducible example. [[link to full example](https://github.com/UrsDeSwardt/rquickjs-issue)] ```rust use std::time::{Duration, Instant}; use rquickjs::{AsyncContext, AsyncRuntime, async_with}; const SCRIPT: &str = r#" async function example() { while (true) { await Promise.resolve(); } } example(); "#; #[tokio::main] async fn main() { let runtime = AsyncRuntime::new().expect("Unable to create runtime"); let context = AsyncContext::full(&runtime) .await .expect("Unable to create context"); let timeout = Duration::from_secs(1); let start_time = Instant::now(); runtime .set_interrupt_handler(Some(Box::new(move || start_time.elapsed() >= timeout))) .await; let _ = async_with!(context => |ctx| { ctx.eval::<(), _>(SCRIPT) }) .await; runtime.idle().await; } ```
0 条评论