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
While trying a few things in debug-build of bun I stumbled upon this bug, which is likely related to #9998 (the reason I got into debugging in the first place)
setTimeout can be arbitrarily large number - it only need to wait for worker to exit before we can call terminate()
import{Worker,isMainThread}from"node:worker_threads"if(isMainThread){constworker=newWorker(__filename);setTimeout(()=>worker.terminate(),60);}else{// worker does not need to do anything}
What is the expected behavior?
Process does not hang and exits correctly
What do you see instead?
Process hangs
Additional information
I could not build bun in WSL (while using ManjaroWSL bun-debug crashes every single time with SIGABRT), so I was able to test Windows version only, but it is likely to reproduce on Linux too
The most bizarre thing I noticed while debugging is that curly braces around setTimeout lambda body actually prevent bug to happen
Replacing setTimeout(() => worker.terminate(), 60);
with setTimeout(() => { worker.terminate() }, 60);
resulting in process not being stuck
And there's no need to do any IO, repro works just fine when worker does not do anything - it seems only required condition is to request termination on worker that is already exited
zawodskoj
changed the title
Process is stuck after terminating worker thread while performing IO
Process is stuck after attempting to terminate already-exited worker
May 26, 2024
What version of Bun is running?
1.1.9-debug+bb13798d9
What platform is your computer?
Microsoft Windows NT 10.0.22631.0 x64
What steps can reproduce the bug?
While trying a few things in debug-build of bun I stumbled upon this bug, which is likely related to #9998 (the reason I got into debugging in the first place)
setTimeout can be arbitrarily large number - it only need to wait for worker to exit before we can call
terminate()
What is the expected behavior?
Process does not hang and exits correctly
What do you see instead?
Process hangs
Additional information
I could not build bun in WSL (while using ManjaroWSL bun-debug crashes every single time with SIGABRT), so I was able to test Windows version only, but it is likely to reproduce on Linux too
Debug logs: https://gist.github.com/zawodskoj/d6c2569db71ac23e131502266d8e6769
The text was updated successfully, but these errors were encountered: