Issue 1:
Preflight Checklist

I have read the Contributing Guidelines for this project.

I agree to follow the Code of Conduct that this project adheres to.

I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

Electron Version:

9.1.0

Operating System:

Windows 10 (19041, 18363, 18362, 16299)

Last Known Working Electron version:

N/A

Expected Behavior

The application should not crash.

Actual Behavior

The application crashes.

To Reproduce

This seems happening sporadically when application exits (all windows get closed, destroyed and app is quit).

It happens only on Windows, MacOS does not seem to affected.

My code snippet:

app.removeAllListeners('window-all-closed')
BrowserWindow.getAllWindows().forEach((browserWindow) => {
browserWindow.close()
browserWindow.destroy()
})
app.quit()

Stack Trace

Pastebin: https://pastebin.com/raw/MYvbpWe2

Snippet:

Fatal Error: EXCEPTION_ACCESS_VIOLATION_READ

Thread 10196 Crashed:
0 MyApp.exe 0x7ff75f43a632 [inlined] base::internal::UncheckedObserverAdapter::IsEqual (observer_list_internal.h:30)
1 MyApp.exe 0x7ff75f43a632 [inlined] base::ObserverList<T>::RemoveObserver::<T>::operator() (observer_list.h:283)
2 MyApp.exe 0x7ff75f43a632 [inlined] std::__1::find_if (algorithm:933)
3 MyApp.exe 0x7ff75f43a632 base::ObserverList<T>::RemoveObserver (observer_list.h:281)
4 MyApp.exe 0x7ff76101f28c extensions::ProcessManager::Shutdown (process_manager.cc:289)
5 MyApp.exe 0x7ff761e3a08d [inlined] DependencyManager::ShutdownFactoriesInOrder (dependency_manager.cc:127)
6 MyApp.exe 0x7ff761e3a08d DependencyManager::DestroyContextServices (dependency_manager.cc:83)
7 MyApp.exe 0x7ff75f2e8de6 electron::ElectronBrowserContext::~ElectronBrowserContext (electron_browser_context.cc:158)
8 MyApp.exe 0x7ff75f2e9abf electron::ElectronBrowserContext::~ElectronBrowserContext (electron_browser_context.cc:154)
9 MyApp.exe 0x7ff75f287a9d [inlined] base::RefCountedDeleteOnSequence<T>::Release (ref_counted_delete_on_sequence.h:52)
10 MyApp.exe 0x7ff75f287a9d [inlined] scoped_refptr<T>::Release (scoped_refptr.h:322)
11 MyApp.exe 0x7ff75f287a9d [inlined] scoped_refptr<T>::~scoped_refptr (scoped_refptr.h:224)
12 MyApp.exe 0x7ff75f287a9d electron::api::Session::~Session (electron_api_session.cc:313)
13 MyApp.exe 0x7ff75f28cdaf electron::api::Session::~Session (electron_api_session.cc:294)
14 MyApp.exe 0x7ff75f2eb641 [inlined] base::OnceCallback<T>::Run (callback.h:98)
15 MyApp.exe 0x7ff75f2eb641 electron::ElectronBrowserMainParts::PostMainMessageLoopRun (electron_browser_main_parts.cc:545)
16 MyApp.exe 0x7ff760a01750 content::BrowserMainLoop::ShutdownThreadsAndCleanUp (browser_main_loop.cc:1095)
17 MyApp.exe 0x7ff760a031a6 content::BrowserMainRunnerImpl::Shutdown (browser_main_runner_impl.cc:178)
18 MyApp.exe 0x7ff7609fee69 content::BrowserMain (browser_main.cc:49)
19 MyApp.exe 0x7ff76090405c content::RunBrowserProcessMain (content_main_runner_impl.cc:530)
20 MyApp.exe 0x7ff760904c00 content::ContentMainRunnerImpl::RunServiceManager (content_main_runner_impl.cc:980)
21 MyApp.exe 0x7ff7609048c2 content::ContentMainRunnerImpl::Run (content_main_runner_impl.cc:879)
22 MyApp.exe 0x7ff761870252 service_manager::Main (main.cc:454)
23 MyApp.exe 0x7ff75fcd8265 content::ContentMain (content_main.cc:19)
24 MyApp.exe 0x7ff75f23140a wWinMain (electron_main.cc:210)
25 MyApp.exe 0x7ff7646a6e91 [inlined] invoke_main (exe_common.inl:118)
26 MyApp.exe 0x7ff7646a6e91 __scrt_common_main_seh (exe_common.inl:288)
27 KERNEL32.DLL 0x7ffed8a97033 BaseThreadInitThunk
28 ntdll.dll 0x7ffed97dcec0 RtlUserThreadStart

Additional Information

This seems a crash on shutdown/destroy of windows (from base::Process::Terminate (process_win.cc), not sure if it's chromium-related (https://chromium.googlesource.com/chromium/src/+/master/docs/shutdown.md)

Issue 2:
Detected in CI: https://app.circleci.com/pipelines/github/electron/electron/31161/workflows/e022a2a8-d5fb-47b4-806f-84f69ecf0a8a/jobs/686542

Received signal 11 SEGV_MAPERR ffffffffffffffff
0 Electron Framework 0x0000000114bcb869 base::debug::CollectStackTrace(void**, unsigned long) + 9
1 Electron Framework 0x0000000114ac6203 base::debug::StackTrace::StackTrace() + 19
2 Electron Framework 0x0000000114bcb731 base::debug::(anonymous namespace)::StackDumpSignalHandler(int, __siginfo*, void*) + 2385
3 libsystem_platform.dylib 0x00007fff6fcda5fd _sigtramp + 29
4 ??? 0x00007ff9fa10d6e0 0x0 + 140711618991840
5 Electron Framework 0x0000000114710a51 extensions::ProcessManager::Shutdown() + 33
6 Electron Framework 0x000000011651d4fc DependencyManager::DestroyContextServices(void*) + 140
7 Electron Framework 0x000000010f34d708 electron::ElectronBrowserContext::~ElectronBrowserContext() + 184
8 Electron Framework 0x000000010f34d9fe electron::ElectronBrowserContext::~ElectronBrowserContext() + 14
9 Electron Framework 0x000000010f35160d std::__1::__tree<std::__1::__value_type<electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr<electron::ElectronBrowserContext, std::__1::default_delete<electron::ElectronBrowserContext> > >, std::__1::__map_value_compare<electron::ElectronBrowserContext::PartitionKey, std::__1::__value_type<electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr<electron::ElectronBrowserContext, std::__1::default_delete<electron::ElectronBrowserContext> > >, std::__1::less<electron::ElectronBrowserContext::PartitionKey>, true>, std::__1::allocator<std::__1::__value_type<electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr<electron::ElectronBrowserContext, std::__1::default_delete<electron::ElectronBrowserContext> > > > >::destroy(std::__1::__tree_node<std::__1::__value_type<electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr<electron::ElectronBrowserContext, std::__1::default_delete<electron::ElectronBrowserContext> > >, void*>*) + 61
10 Electron Framework 0x000000010f3515f6 std::__1::__tree<std::__1::__value_type<electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr<electron::ElectronBrowserContext, std::__1::default_delete<electron::ElectronBrowserContext> > >, std::__1::__map_value_compare<electron::ElectronBrowserContext::PartitionKey, std::__1::__value_type<electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr<electron::ElectronBrowserContext, std::__1::default_delete<electron::ElectronBrowserContext> > >, std::__1::less<electron::ElectronBrowserContext::PartitionKey>, true>, std::__1::allocator<std::__1::__value_type<electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr<electron::ElectronBrowserContext, std::__1::default_delete<electron::ElectronBrowserContext> > > > >::destroy(std::__1::__tree_node<std::__1::__value_type<electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr<electron::ElectronBrowserContext, std::__1::default_delete<electron::ElectronBrowserContext> > >, void*>*) + 38
11 Electron Framework 0x000000010f35121b electron::ElectronBrowserMainParts::PostMainMessageLoopRun() + 219
12 Electron Framework 0x00000001134a7477 content::BrowserMainLoop::ShutdownThreadsAndCleanUp() + 647
13 Electron Framework 0x00000001134a9510 content::BrowserMainRunnerImpl::Shutdown() + 224
14 Electron Framework 0x00000001134a3c57 content::BrowserMain(content::MainFunctionParams const&) + 279
15 Electron Framework 0x00000001132bd757 content::ContentMainRunnerImpl::RunServiceManager(content::MainFunctionParams&, bool) + 1191
16 Electron Framework 0x00000001132bd283 content::ContentMainRunnerImpl::Run(bool) + 467
17 Electron Framework 0x00000001110e92be content::RunContentProcess(content::ContentMainParams const&, content::ContentMainRunner*) + 2782
18 Electron Framework 0x00000001110e93ac content::ContentMain(content::ContentMainParams const&) + 44
19 Electron Framework 0x000000010f2285a9 ElectronMain + 137
20 Electron 0x0000000108e99631 main + 289
21 libdyld.dylib 0x00007fff6faddcc9 start + 1
[end of stack trace]