Skip to content

fix(engine): don't crash when the runtime is dropped without close()#14

Open
wytzepiet wants to merge 1 commit into
fluttercandies:mainfrom
wytzepiet:feat/bridge-drop-fix
Open

fix(engine): don't crash when the runtime is dropped without close()#14
wytzepiet wants to merge 1 commit into
fluttercandies:mainfrom
wytzepiet:feat/bridge-drop-fix

Conversation

@wytzepiet
Copy link
Copy Markdown

Fixes #8.

The fjs bridge function captured the Ctx it runs in. Since the function lives on the global object, that made the context reference itself — so it could never be freed. Dropping the runtime without close() (e.g. via Dart's GC) then aborted in JS_FreeRuntime:

Assertion failed: (list_empty(&rt->gc_obj_list)), quickjs.c:2308

Fix: take ctx as a call-time argument instead of capturing it. The bridge function no longer pins its own context, so the runtime frees cleanly — on both the close() and drop paths. No API change.

Adds a test that drops an engine-with-bridge without close(); it aborted before this change and passes now.

🤖 Generated with Claude Code

The fjs bridge function captured the Ctx it runs in. Since the function
lives on the global object, the context referenced itself and could never
be freed, so dropping the runtime without close() (e.g. via Dart's GC)
aborted in JS_FreeRuntime:

  Assertion failed: (list_empty(&rt->gc_obj_list)), quickjs.c:2308

Take ctx as a call-time argument instead of capturing it. The bridge
function no longer pins its context, so the runtime frees cleanly on both
the close() and drop paths. No API change.

Adds a test that drops an engine-with-bridge without close(); it aborted
before this change and passes now.

Fixes fluttercandies#8.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@iota9star
Copy link
Copy Markdown
Member

Review result:

No blocking issues found in this PR. The runtime-drop cleanup path and regression coverage look consistent with the intended behavior, and cargo test --manifest-path libfjs/Cargo.toml passed locally with 534 tests.

@wytzepiet wytzepiet marked this pull request as ready for review June 1, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JS_FreeRuntime SIGABRT when Dart GC finalizes JsAsyncRuntime (non-empty gc_obj_list)

2 participants