You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue arose while consuming the Webview foreign library.
Webview opens a native OS browser window (webview), blocking the calling (Worker) thread until terminated. In order to interact with the Webview API after a browser window is opened, calls need to be made from the parent thread.
The bun minimal reproduction illustrates how Webview API commands using JSCallback work from the worker thread, but fail from the parent thread.
In Deno, the minimal reproduction works as expected using "node:worker_threads"
The Bun minimal reproduction fails with native Worker and "node:worker_threads"
Webview FFI commands not involving JSCallback work as expected from the parent thread.
I have thus formed an opinion that the issue does not lie with Bun Worker, but specifically with Bun FFI JSCallback.
In order to run the minimal reproduction (for linux x64) , some OS dependencies are required. minimal.repro.zip contains all of the minimal reproduction code, as well as "libwebview.so" (the Webview library for linux x64)
Relevant log output
Overriding existing handler for signal 10. Set JSC_SIGNAL_FOR_GC if you want WebKit to use a different signal
============================================================
Bun v1.1.39 (1d485617) Linux x64
Linux Kernel v6.1.0 | glibc v2.36
CPU: sse42 popcnt avx avx2
Args: "bun""./index.ts"
Features: jsc tsconfig workers_spawned
Builtins: "bun:ffi""bun:main""node:path"
Elapsed: 1229ms | User: 152ms | Sys: 114ms
RSS: 1.07GB | Peak: 0.16GB | Commit: 1.07GB | Faults: 0
panic(main thread): Segmentation fault at address 0x40
oh no: Bun has crashed. This indicates a bug in Bun, not your code.
To send a redacted crash report to Bun's team,please file a GitHub issue using the link below: https://bun.report/1.1.39/la11d48561Ihgg8//DoqqomEk0/pvB__A2AgEIllegal instruction
Stack Trace (bun.report)
Bun v1.1.39 (1d48561) on linux x86_64 [AutoCommand]
I have hacked a workaround in this gist (not a solution, but it narrows down the issue).
When JSCallback pointers are taken in the worker thread and passed by IPC to the parent thread for consumption as parameters, the example runs as expected.
This points the issue to JSCallback.ptr not being memory safe across threads in the same process.
Also to note: converting pointers to/from SharedArrayBuffer between messaging prevents Bun panicking, but the functions that include JSCallback still fail to execute.
How can we reproduce the crash?
This issue arose while consuming the Webview foreign library.
Webview opens a native OS browser window (webview), blocking the calling (Worker) thread until terminated. In order to interact with the Webview API after a browser window is opened, calls need to be made from the parent thread.
The bun minimal reproduction illustrates how Webview API commands using
JSCallback
work from the worker thread, but fail from the parent thread.Observations:
Worker
and "node:worker_threads"JSCallback
work as expected from the parent thread.I have thus formed an opinion that the issue does not lie with Bun
Worker
, but specifically with Bun FFIJSCallback
.In order to run the minimal reproduction (for linux x64) , some OS dependencies are required.
minimal.repro.zip contains all of the minimal reproduction code, as well as "libwebview.so" (the Webview library for linux x64)
Relevant log output
Stack Trace (bun.report)
Bun v1.1.39 (
1d48561
) on linux x86_64 [AutoCommand]Segmentation fault at address 0x00000040
ld-temp.o:0
:icudt75_dat
Features: workers_spawned, jsc, tsconfig, tsconfig
The text was updated successfully, but these errors were encountered: