apple/pkl · error
fatal: failed to attach response dispatch thread to isolate.
Error message
fatal: failed to attach response dispatch thread to isolate.
What it means
Fatal check in libpkl's pkl_dispatch_worker: before polling for Pkl responses, the worker thread must attach to the GraalVM isolate via graal_attach_thread; a non-zero return means the native thread could not join the isolate, so the process aborts. Typically caused by isolate teardown concurrent with dispatch or resource exhaustion.
Solutions
- Ensure pkl_close is not racing the dispatch worker (close only after stopping message traffic).
- Check GraalVM native-image logs for isolate creation/attach limits.
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at libpkl/src/main/c/pkl.c:68 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/c796a20a0d7d1e5c.
Report an issue: GitHub.
Appendix: source
Thrown at libpkl/src/main/c/pkl.c:68
};
/**
* Polls for messages coming from Pkl and sends them back to the handler.
*
* Ensures that calls into Pkl are wrapped with graal_attach_thread/graal_detach_thread, and
* calls back to the handler are _not_ inside the GraalVM thread context.
*/
#ifdef _WIN32
static DWORD WINAPI pkl_dispatch_worker(LPVOID arg) {
#else
static void* pkl_dispatch_worker(void *arg) {
#endif
const pkl_exec_t *pexec = (pkl_exec_t*) arg;
for (;;) {
graal_isolatethread_t *thread;
if (graal_attach_thread(pexec->isolate, &thread) != 0) {
fprintf(stderr,
"fatal: failed to attach response dispatch thread to isolate.\n");
abort();
}
char *message = NULL;
const int length = pkl_internal_poll_response(thread, &message);
if (graal_detach_thread(thread) != 0) {
fprintf(stderr,
"fatal: failed to detach response dispatch thread from isolate.\n");
abort();
}
if (length < 0) {
// pkl_internal_server_stop has been called and the queue is drained
break;
}
pexec->handler(length, message, pexec->userData);View on GitHub (pinned to f3efcbfc9b)