Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Electron main process crashes on exit (version 10.1.3) #26019

Closed
3 tasks done
vyunikov opened this issue Oct 17, 2020 · 14 comments
Closed
3 tasks done

Electron main process crashes on exit (version 10.1.3) #26019

vyunikov opened this issue Oct 17, 2020 · 14 comments

Comments

@vyunikov
Copy link

vyunikov commented Oct 17, 2020

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:
    • v10.1.3
  • Operating System:
    • Windows 10
  • Last Known Working Electron version:
    • v9.2.1

Expected Behavior

Electron app should exit normally

Actual Behavior

My electron-based app crashes on exit

I recently updated from electron 9.2.1 to 10.1.3 and my app started crashing on exit (crashes when I close the main window).
It didn't crash earlier on 9.x. I use my custom native module with electron, so maybe it's related somehow.
Stack trace:

 	ntdll.dll!RtlReportCriticalFailure()	Unknown
 	ntdll.dll!RtlpHeapHandleError()	Unknown
 	ntdll.dll!RtlpHpHeapHandleError()	Unknown
 	ntdll.dll!RtlpLogHeapFailure()	Unknown
 	ntdll.dll!RtlpFreeHeapInternal()	Unknown
 	ntdll.dll!RtlFreeHeap()	Unknown
 	electron.exe!electron::InspectableWebContentsViewViews::~InspectableWebContentsViewViews() Line 110	C++
	electron.exe!electron::InspectableWebContentsViewViews::~InspectableWebContentsViewViews() Line 106	C++
 	electron.exe!electron::InspectableWebContentsImpl::~InspectableWebContentsImpl() Line 385	C++
 	electron.exe!electron::InspectableWebContentsImpl::~InspectableWebContentsImpl() Line 374	C++
 	electron.exe!electron::api::WebContents::~WebContents() Line 699	C++
 	electron.exe!electron::api::WebContents::~WebContents() Line 673	C++
 	electron.exe!electron::ElectronBrowserMainParts::PostMainMessageLoopRun() Line 545	C++
 	electron.exe!content::BrowserMainLoop::ShutdownThreadsAndCleanUp() Line 1041	C++
 	electron.exe!content::BrowserMainRunnerImpl::Shutdown() Line 180	C++
 	electron.exe!content::BrowserMain(const content::MainFunctionParams & parameters) Line 52	C++
 	electron.exe!content::ContentMainRunnerImpl::RunServiceManager(content::MainFunctionParams & main_params, bool start_service_manager_only) Line 996	C++
 	electron.exe!content::ContentMainRunnerImpl::Run(bool start_service_manager_only) Line 883	C++
 	electron.exe!service_manager::Main(const service_manager::MainParams & params) Line 453	C++
 	electron.exe!content::ContentMain(const content::ContentMainParams & params) Line 19	C++
 	electron.exe!wWinMain(HINSTANCE__ * instance, HINSTANCE__ *, wchar_t * cmd, int) Line 210	C++

@ckerr
Copy link
Member

ckerr commented Oct 19, 2020

Hi @vyunikov, thanks for reaching out!

Researching issues that depend on third-party code is usually not feasible for the Electron team due to the time that would be required to research reported issues with open-ended dependencies.

Would it be possible for you to fork electron-quick-start for a small app that reproduces the issue by itself without other code?

Stand-alone test cases make fixing issues go more smoothly: it ensure everyone's looking at the same issue, it removes all unnecessary variables from the equation, and it can also provide the basis for automated regression tests.

I'm adding the blocked/needs-repro label for this reason. After you make a test case (a gist is preferred since gists can be loaded directly into Electron Fiddle for testing), please link to it in a followup comment.

@ckerr ckerr added the blocked/need-repro Needs a test case to reproduce the bug label Oct 19, 2020
@vyunikov
Copy link
Author

Hi @ckerr
Thanks for your response. I'll try to narrow it down.
I thought maybe the stack trace points something out?

@quanglam2807
Copy link
Contributor

One of my users reports the same issue. This is what he got from Windows Reliability History

Description
Faulting Application Path:    C:\Users\scgf\WebCatalog Apps\Note Station\Note Station.exe

Problem signature
Problem Event Name:    APPCRASH
Application Name:    Note Station.exe
Application Version:    11.1.0.0
Application Timestamp:    5f931470
Fault Module Name:    StackHash_0531
Fault Module Version:    10.0.19041.546
Fault Module Timestamp:    5b56177b
Exception Code:    c0000374
Exception Offset:    PCH_94_FROM_ntdll+0x000000000009C8E4
OS Version:    10.0.19041.2.0.0.256.48
Locale ID:    2057
Additional Information 1:    0531
Additional Information 2:    0531edad36a7184addf19c0209cc8fd5
Additional Information 3:    bae1
Additional Information 4:    bae1a6ab6e70a2c449fe46631043ab44

Files that help describe the problem
WERInternalMetadata.xml

@quanglam2807
Copy link
Contributor

In my case, the bug starts to occur after updating to Electron 10. As the app crashes when exit, it doesn't log anything in the console (where can I get the stack trace?). But it always shows up in the Windows Reliability Monitor every time I exit the app

Capture

Description
Faulting Application Path:	C:\Users\quanglam2807\WebCatalog Apps\Messenger\Messenger.exe

Problem signature
Problem Event Name:	APPCRASH
Application Name:	Messenger.exe
Application Version:	11.1.0.0
Application Timestamp:	5f931470
Fault Module Name:	StackHash_0847
Fault Module Version:	10.0.19041.546
Fault Module Timestamp:	5b56177b
Exception Code:	c0000374
Exception Offset:	PCH_4F_FROM_ntdll+0x000000000009C8E4
OS Version:	10.0.19042.2.0.0.256.48
Locale ID:	1033
Additional Information 1:	0847
Additional Information 2:	0847a98bcdcfa9d6e729eb18fa8731fc
Additional Information 3:	fea0
Additional Information 4:	fea07570b510ce818217d61ad33f6c02

Extra information about the problem
Bucket ID:	3343f3f266bf05b7910976815a17dc44 (1227642671369542724)

Btw, I'm working on an Electron-based app builder so users can create apps with different names (that's why the EXE name is different). But they all use the same code.
.

@quanglam2807
Copy link
Contributor

In the case, I managed to resolve bug by win.setBrowserView(null) and then destroy the BrowserViews in app.on('before-quit')

@vyunikov
Copy link
Author

Thanks @quanglam2807 for pointing our the problem and potential work around for this.

@vyunikov
Copy link
Author

vyunikov commented Oct 26, 2020

@ckerr As per the comments above the problem happens when BrowserView is used. I created a simple example based on electron-quick-start as you suggested:
https://github.com/vyunikov/electron-quick-start/tree/crash-on-exit

In order to reproduce you can just clone my fork: https://github.com/vyunikov/electron-quick-start.git
And switch to crash-on-exit branch.
Then start an app: npm start.
Once it starts, just close the window and app will crash.

In order to apply a workaround mentioned by @quanglam2807 you can set a variable APPLY_BROWSER_VIEW_FIX to true in main.js. If BrowserView is not used (like a clear electron-quick-start), app doesn't crash.

@vyunikov
Copy link
Author

Just noticed this PR: #25411
Is it related?

@nornagon nornagon added component/BrowserView and removed blocked/need-repro Needs a test case to reproduce the bug labels Oct 26, 2020
@poiru
Copy link
Contributor

poiru commented Dec 9, 2020

We're also getting lots of crash reports about this with Electron 10.1.6. 99% are on Windows 7. I can reliably repro on Windows 7 SP1 when closing a window with a browser view attached.

OS Version: Windows 6.1.7601 (23714)
Report Version: 104

Crashed Thread: 8068

Application Specific Information:
Fatal Error: EXCEPTION_ACCESS_VIOLATION_READ

Thread 8068 Crashed:
0   Figma.exe                       0x13fcd7ec8         [inlined] std::__1::default_delete<T>::operator() (memory:2378)
1   Figma.exe                       0x13fcd7ec8         [inlined] std::__1::unique_ptr<T>::reset (memory:2633)
2   Figma.exe                       0x13fcd7ec8         [inlined] std::__1::unique_ptr<T>::~unique_ptr (memory:2587)
3   Figma.exe                       0x13fcd7ec8         electron::InspectableWebContentsImpl::~InspectableWebContentsImpl (inspectable_web_contents_impl.cc:385)
4   Figma.exe                       0x13fcdb7df         electron::InspectableWebContentsImpl::~InspectableWebContentsImpl (inspectable_web_contents_impl.cc:374)
5   Figma.exe                       0x14219459b         [inlined] base::OnceCallback<T>::Run (callback.h:99)
6   Figma.exe                       0x14219459b         base::TaskAnnotator::RunTask (task_annotator.cc:142)
7   Figma.exe                       0x142a48273         base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl (thread_controller_with_message_pump_impl.cc:333)
8   Figma.exe                       0x142a47f57         base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork (thread_controller_with_message_pump_impl.cc:253)
9   Figma.exe                       0x1421bf040         base::MessagePumpForUI::DoRunLoop (message_pump_win.cc:230)
10  Figma.exe                       0x1421bea54         base::MessagePumpWin::Run (message_pump_win.cc:86)
11  Figma.exe                       0x142a4886d         base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run (thread_controller_with_message_pump_impl.cc:452)
12  Figma.exe                       0x14217e49b         base::RunLoop::Run (run_loop.cc:124)
13  Figma.exe                       0x141690710         [inlined] content::BrowserMainLoop::MainMessageLoopRun (browser_main_loop.cc:1440)
14  Figma.exe                       0x141690710         content::BrowserMainLoop::RunMainMessageLoopParts (browser_main_loop.cc:1005)
15  Figma.exe                       0x141692150         content::BrowserMainRunnerImpl::Run (browser_main_runner_impl.cc:150)
16  Figma.exe                       0x14168ddd1         content::BrowserMain (browser_main.cc:47)
17  Figma.exe                       0x14156a9fe         [inlined] content::RunBrowserProcessMain (content_main_runner_impl.cc:524)
18  Figma.exe                       0x14156a9fe         content::ContentMainRunnerImpl::RunServiceManager (content_main_runner_impl.cc:996)
19  Figma.exe                       0x14156a552         content::ContentMainRunnerImpl::Run (content_main_runner_impl.cc:880)
20  Figma.exe                       0x1427047aa         [inlined] service_manager::`anonymous namespace'::CommonSubprocessInit (main.cc:140)
21  Figma.exe                       0x1427047aa         service_manager::Main (main.cc:446)
22  Figma.exe                       0x1407fe56d         content::ContentMain (content_main.cc:19)
23  Figma.exe                       0x13fbd149e         wWinMain (electron_main.cc:210)
24  Figma.exe                       0x145c7b341         [inlined] invoke_main (exe_common.inl:118)

cc @zcbenz

@poiru
Copy link
Contributor

poiru commented Dec 9, 2020

Here's a viable workaround:

browserWindow.on('close', () => {
  browserWindow.setBrowserView(null);
});

@vyunikov
Copy link
Author

@poiru That happens on Windows 10 either, that's not just Win 7 issue

@nornagon
Copy link
Member

nornagon commented Feb 5, 2021

Here's a Fiddle-ready repro: https://gist.github.com/1d1190d6c6d971fe7b938d0d12be8071

I can repro on Win 10, but not Mac.

@nornagon
Copy link
Member

nornagon commented Feb 5, 2021

This appears to be fixed in 11.x, in the range 11.0.0-nightly.20200709...11.0.0-nightly.20200716, likely by #23578.

@codebytere
Copy link
Member

Closing as fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants