apple/pkl · error
fatal: failed to tear down graal isolate.
Error message
fatal: failed to tear down graal isolate.
What it means
Fatal check in pkl_close: graal_tear_down_isolate returned non-zero, meaning the GraalVM isolate could not be shut down cleanly; the process aborts because a half-torn-down isolate is unrecoverable. Typically indicates lingering threads attached to, or work still running in, the isolate.
Solutions
- Ensure all evaluation work and the dispatch worker are stopped before pkl_close (pkl_internal_server_stop already does this — check for extra attached threads).
- Call pkl_close exactly once, from the same thread that ran pkl_init.
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at libpkl/src/main/c/pkl.c:239 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08).
Data as JSON: /api/errors/8303be21ca9c2192.
Report an issue: GitHub.
Appendix: source
Thrown at libpkl/src/main/c/pkl.c:239
}
return -1;
}
graal_isolatethread_t *thread = graal_get_current_thread(pexec->isolate);
if (thread != pexec->isolateThread) {
if (error != NULL) {
error->message = "called into pkl_close from different thread";
}
return PKL_ERR_THREAD;
}
// pkl_internal_server_stop unblocks queue_thread's pending/next poll call, so the join
// below is guaranteed to return; only then is it safe to tear down the isolate.
pkl_internal_server_stop(thread);
pkl_stop_dispatch_worker(pexec);
if (graal_tear_down_isolate(thread) != 0) {
fprintf(stderr, "fatal: failed to tear down graal isolate.\n");
abort();
}
free(pexec);
if (error != NULL) {
error->message = NULL;
}
return 0;
}
const char* pkl_version() {
return PKL_VERSION;
}
View on GitHub (pinned to f3efcbfc9b)