<h3 dir="auto">Preflight Checklist</h3>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have read the <a href="https://github.com/electron/electron/blob/master/CONTRIBUTING.md">Contributing Guidelines</a> for this project.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I agree to follow the <a href="https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md">Code of Conduct</a> that this project adheres to.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the issue tracker for an issue that matches the one I want to file, without success.</li>
</ul>
<h3 dir="auto">Issue Details</h3>
<ul dir="auto">
<li>
<p dir="auto"><strong>Electron Version:</strong></p>
<ul dir="auto">
<li>10.1.4</li>
</ul>
</li>
<li>
<p dir="auto"><strong>Operating System:</strong></p>
<ul dir="auto">
<li>both, macOS 10.14.6 and ArchLinux kernel 5.8.5-arch1-1 (did not test on Windows)</li>
</ul>
</li>
<li>
<p dir="auto"><strong>Last Known Working Electron version:</strong></p>
<ul dir="auto">
<li>9.3.2</li>
</ul>
</li>
</ul>
<h3 dir="auto">Expected Behavior</h3>

<p dir="auto">Electron quits normally</p>
<h3 dir="auto">Actual Behavior</h3>

<p dir="auto">Electron crashes with SIGSEGV</p>
<h3 dir="auto">To Reproduce</h3>

<p dir="auto">Here's a minimal code example that crashes electron</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const {Worker} = require('worker_threads')
const {app} = require('electron')

const worker_code = `
  process.exit(0)
`

app.on('ready', ()=&gt;{
  const worker = new Worker(worker_code, {
    eval: true
  })

  worker.on('exit', code=&gt;{
    console.log('exited with code', code)
  })

  setTimeout( ()=&gt;{
    app.quit()
  }, 1000)
})
"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-kos">{</span>Worker<span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'worker_threads'</span><span class="pl-kos">)</span>
<span class="pl-k">const</span> <span class="pl-kos">{</span>app<span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'electron'</span><span class="pl-kos">)</span>

<span class="pl-k">const</span> <span class="pl-s1">worker_code</span> <span class="pl-c1">=</span> <span class="pl-s">`</span>
<span class="pl-s">  process.exit(0)</span>
<span class="pl-s">`</span>

<span class="pl-s1">app</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'ready'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-c1">=&gt;</span><span class="pl-kos">{</span>
  <span class="pl-k">const</span> <span class="pl-s1">worker</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">Worker</span><span class="pl-kos">(</span><span class="pl-s1">worker_code</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
    <span class="pl-c1">eval</span>: <span class="pl-c1">true</span>
  <span class="pl-kos">}</span><span class="pl-kos">)</span>

  <span class="pl-s1">worker</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'exit'</span><span class="pl-kos">,</span> <span class="pl-s1">code</span><span class="pl-c1">=&gt;</span><span class="pl-kos">{</span>
    <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'exited with code'</span><span class="pl-kos">,</span> <span class="pl-s1">code</span><span class="pl-kos">)</span>
  <span class="pl-kos">}</span><span class="pl-kos">)</span>

  <span class="pl-en">setTimeout</span><span class="pl-kos">(</span> <span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-c1">=&gt;</span><span class="pl-kos">{</span>
    <span class="pl-s1">app</span><span class="pl-kos">.</span><span class="pl-en">quit</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
  <span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-c1">1000</span><span class="pl-kos">)</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span></pre></div>
<p dir="auto">To reproduce: <a href="https://gist.github.com/d3b1724eadcc8a605dd5f7230158f05d">https://gist.github.com/d3b1724eadcc8a605dd5f7230158f05d</a></p>
<p dir="auto">Repros for me on 10.1.3, but not current master.</p>
<p dir="auto">Stack trace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="* thread #1, name = 'CrBrowserMain', queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x18)
  * frame #0: 0x000000010656bb93 Electron Framework`node::NodePlatform::AddIsolateFinishedCallback(v8::Isolate*, void (*)(void*), void*) [inlined] std::__1::shared_ptr&lt;node::PerIsolatePlatformData&gt;::operator bool(this=&lt;unavailable&gt;) const at memory:3851:68 [opt]
    frame #1: 0x000000010656bb93 Electron Framework`node::NodePlatform::AddIsolateFinishedCallback(this=0x0000000109049c20, isolate=0x0000147000000000, cb=(Electron Framework`node::Environment::AddArrayBufferAllocatorToKeepAliveUntilIsolateDispose(std::__1::shared_ptr&lt;v8::ArrayBuffer::Allocator&gt;)::$_10::__invoke(void*) [inlined] node::Environment::AddArrayBufferAllocatorToKeepAliveUntilIsolateDispose(std::__1::shared_ptr&lt;v8::ArrayBuffer::Allocator&gt;)::$_10::operator()(void*) const at env.cc:1101
Electron Framework`node::Environment::AddArrayBufferAllocatorToKeepAliveUntilIsolateDispose(std::__1::shared_ptr&lt;v8::ArrayBuffer::Allocator&gt;)::$_10::__invoke(void*) at env.cc:1101), data=0x0000000112d3acf0)(void*), void*) at node_platform.cc:355 [opt]
    frame #2: 0x00000001064b99c6 Electron Framework`node::Environment::AddArrayBufferAllocatorToKeepAliveUntilIsolateDispose(this=0x0000000108880000, allocator=nullptr) at env.cc:1101:15 [opt]
    frame #3: 0x00000001065a209a Electron Framework`node::worker::(anonymous namespace)::SABLifetimePartner::CleanupHook(data=&lt;unavailable&gt;) at sharedarraybuffer_metadata.cc:75:18 [opt]
    frame #4: 0x00000001064b58e6 Electron Framework`node::Environment::RunCleanup(this=0x0000000108880000) at env.cc:628:7 [opt]
    frame #5: 0x00000001064810be Electron Framework`node::FreeEnvironment(env=0x0000000108880000) at environment.cc:307:8 [opt]
    frame #6: 0x0000000100208336 Electron Framework`electron::ElectronBrowserMainParts::PostMainMessageLoopRun() [inlined] std::__1::default_delete&lt;electron::NodeEnvironment&gt;::operator(this=&lt;unavailable&gt;, __ptr=0x00000001090571e0)(electron::NodeEnvironment*) const at memory:2378:5 [opt]
    frame #7: 0x000000010020832e Electron Framework`electron::ElectronBrowserMainParts::PostMainMessageLoopRun() [inlined] std::__1::unique_ptr&lt;electron::NodeEnvironment, std::__1::default_delete&lt;electron::NodeEnvironment&gt; &gt;::reset(this=0x0000000109049608, __p=0x0000000000000000) at memory:2633 [opt]
    frame #8: 0x000000010020831d Electron Framework`electron::ElectronBrowserMainParts::PostMainMessageLoopRun(this=0x00000001090495c0) at electron_browser_main_parts.cc:555 [opt]
    frame #9: 0x0000000101e5e6fe Electron Framework`content::BrowserMainLoop::ShutdownThreadsAndCleanUp(this=&lt;unavailable&gt;) at browser_main_loop.cc:1040:13 [opt]
    frame #10: 0x0000000101e60081 Electron Framework`content::BrowserMainRunnerImpl::Shutdown(this=0x0000000109046b00) at browser_main_runner_impl.cc:178:17 [opt]
    frame #11: 0x0000000101e5b8cd Electron Framework`content::BrowserMain(parameters=0x00007ffeefbfede8) at browser_main.cc:49:16 [opt]"><pre class="notranslate"><code class="notranslate">* thread #1, name = 'CrBrowserMain', queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x18)
  * frame #0: 0x000000010656bb93 Electron Framework`node::NodePlatform::AddIsolateFinishedCallback(v8::Isolate*, void (*)(void*), void*) [inlined] std::__1::shared_ptr&lt;node::PerIsolatePlatformData&gt;::operator bool(this=&lt;unavailable&gt;) const at memory:3851:68 [opt]
    frame #1: 0x000000010656bb93 Electron Framework`node::NodePlatform::AddIsolateFinishedCallback(this=0x0000000109049c20, isolate=0x0000147000000000, cb=(Electron Framework`node::Environment::AddArrayBufferAllocatorToKeepAliveUntilIsolateDispose(std::__1::shared_ptr&lt;v8::ArrayBuffer::Allocator&gt;)::$_10::__invoke(void*) [inlined] node::Environment::AddArrayBufferAllocatorToKeepAliveUntilIsolateDispose(std::__1::shared_ptr&lt;v8::ArrayBuffer::Allocator&gt;)::$_10::operator()(void*) const at env.cc:1101
Electron Framework`node::Environment::AddArrayBufferAllocatorToKeepAliveUntilIsolateDispose(std::__1::shared_ptr&lt;v8::ArrayBuffer::Allocator&gt;)::$_10::__invoke(void*) at env.cc:1101), data=0x0000000112d3acf0)(void*), void*) at node_platform.cc:355 [opt]
    frame #2: 0x00000001064b99c6 Electron Framework`node::Environment::AddArrayBufferAllocatorToKeepAliveUntilIsolateDispose(this=0x0000000108880000, allocator=nullptr) at env.cc:1101:15 [opt]
    frame #3: 0x00000001065a209a Electron Framework`node::worker::(anonymous namespace)::SABLifetimePartner::CleanupHook(data=&lt;unavailable&gt;) at sharedarraybuffer_metadata.cc:75:18 [opt]
    frame #4: 0x00000001064b58e6 Electron Framework`node::Environment::RunCleanup(this=0x0000000108880000) at env.cc:628:7 [opt]
    frame #5: 0x00000001064810be Electron Framework`node::FreeEnvironment(env=0x0000000108880000) at environment.cc:307:8 [opt]
    frame #6: 0x0000000100208336 Electron Framework`electron::ElectronBrowserMainParts::PostMainMessageLoopRun() [inlined] std::__1::default_delete&lt;electron::NodeEnvironment&gt;::operator(this=&lt;unavailable&gt;, __ptr=0x00000001090571e0)(electron::NodeEnvironment*) const at memory:2378:5 [opt]
    frame #7: 0x000000010020832e Electron Framework`electron::ElectronBrowserMainParts::PostMainMessageLoopRun() [inlined] std::__1::unique_ptr&lt;electron::NodeEnvironment, std::__1::default_delete&lt;electron::NodeEnvironment&gt; &gt;::reset(this=0x0000000109049608, __p=0x0000000000000000) at memory:2633 [opt]
    frame #8: 0x000000010020831d Electron Framework`electron::ElectronBrowserMainParts::PostMainMessageLoopRun(this=0x00000001090495c0) at electron_browser_main_parts.cc:555 [opt]
    frame #9: 0x0000000101e5e6fe Electron Framework`content::BrowserMainLoop::ShutdownThreadsAndCleanUp(this=&lt;unavailable&gt;) at browser_main_loop.cc:1040:13 [opt]
    frame #10: 0x0000000101e60081 Electron Framework`content::BrowserMainRunnerImpl::Shutdown(this=0x0000000109046b00) at browser_main_runner_impl.cc:178:17 [opt]
    frame #11: 0x0000000101e5b8cd Electron Framework`content::BrowserMain(parameters=0x00007ffeefbfede8) at browser_main.cc:49:16 [opt]
</code></pre></div>