Page 1 of 2

Crash on closing the application

PostPosted: Fri Feb 15, 2019 9:19 am
by sikor
Hi,
I have encountered a crash during closing the application that uses CEF.
CEF version: 3578; It happened on Windows; Application is build on x86 .
The crash stack looks like that:
Code: Select all
libcef.dll!Profile::MaybeSendDestroyedNotification() Line 294   C++
libcef.dll!CefBrowserContext::Shutdown() Line 83   C++
libcef.dll!CefBrowserContextImpl::~CefBrowserContextImpl() Line 228   C++
libcef.dll!CefBrowserContextImpl::~CefBrowserContextImpl() Line 217   C++
libcef.dll!CefBrowserContextImpl::RemoveCefRequestContext(CefRequestContextImpl * context) Line 338   C++
libcef.dll!CefRequestContextImpl::~CefRequestContextImpl() Line 150   C++
[External Code]   
libcef.dll!content::BrowserThread::DeleteOnThread<content::BrowserThread::UI>::Destruct<CefImageImpl>(const CefImageImpl * x) Line 147   C++
[External Code]   
libcef.dll!CefBrowserHostImpl::~CefBrowserHostImpl() Line 598   C++
[External Code]   
libcef.dll!CefCppToCRefCounted<CefBrowserCppToC,CefBrowser,_cef_browser_t>::Release() Line 85   C++
libcef.dll!CefCppToCRefCounted<CefAuthCallbackCppToC,CefAuthCallback,_cef_auth_callback_t>::struct_release(_cef_base_ref_counted_t * base) Line 179   C++


Extra note, CefInitialize and CefShutdown are called from the same thread.

The crash happened once till now, but I would like to understand what might be possible causes.

Any thoughts?

Re: Crash on closing the application

PostPosted: Fri Feb 15, 2019 10:03 am
by magreenblatt
Maybe you’re still holding a CefAuthCallback reference after OnBeforeClose for the associated browser?

Re: Crash on closing the application

PostPosted: Mon Feb 18, 2019 3:12 am
by sikor
I quickly checked. I don't use that anywhere.

Re: Crash on closing the application

PostPosted: Thu Feb 21, 2019 3:27 am
by sikor
So, do you have any other advice? Maybe there is a way of checking (some sort of checklist?), if the shutdown is implemented correctly?

Re: Crash on closing the application

PostPosted: Thu Feb 21, 2019 4:27 pm
by magreenblatt
You only provided a partial call stack. What's the rest of it?

Re: Crash on closing the application

PostPosted: Tue Feb 26, 2019 3:15 am
by sikor
Well, this is the full stack:

Code: Select all
libcef.dll!Profile::MaybeSendDestroyedNotification() Line 294   C++
libcef.dll!CefBrowserContext::Shutdown() Line 83   C++
libcef.dll!CefBrowserContextImpl::~CefBrowserContextImpl() Line 228   C++
libcef.dll!CefBrowserContextImpl::~CefBrowserContextImpl() Line 217   C++
libcef.dll!CefBrowserContextImpl::RemoveCefRequestContext(CefRequestContextImpl * context) Line 338   C++
libcef.dll!CefRequestContextImpl::~CefRequestContextImpl() Line 150   C++
[External Code]   
libcef.dll!content::BrowserThread::DeleteOnThread<content::BrowserThread::UI>::Destruct<CefImageImpl>(const CefImageImpl * x) Line 147   C++
[External Code]   
libcef.dll!CefBrowserHostImpl::~CefBrowserHostImpl() Line 598   C++
[External Code]   
libcef.dll!CefCppToCRefCounted<CefBrowserCppToC,CefBrowser,_cef_browser_t>::Release() Line 85   C++
libcef.dll!CefCppToCRefCounted<CefAuthCallbackCppToC,CefAuthCallback,_cef_auth_callback_t>::struct_release(_cef_base_ref_counted_t * base) Line 179   C++
Application.exe!CefCToCppRefCounted<CefContextMenuParamsCToCpp,CefContextMenuParams,_cef_context_menu_params_t>::Release() Line 169   C++
[External Code]   

Re: Crash on closing the application

PostPosted: Tue Feb 26, 2019 5:26 am
by ndesktop
I don't get why stack shows context menu prams > auth callback > browser release > shutdown.
Is this the normal flow?

Re: Crash on closing the application

PostPosted: Tue Feb 26, 2019 6:33 am
by sikor
In terms of ContextMenu, there is a class CefClientHelper, which overrides OnBeforeContextMenu just for:
Code: Select all
void CefClientHandler::OnBeforeContextMenu(
   CefRefPtr<CefBrowser>,
   CefRefPtr<CefFrame>,
   CefRefPtr<CefContextMenuParams>,
   CefRefPtr<CefMenuModel> model
)
{
   model->Clear();
}

The same class overrides CefRequestHandler methods (i.e OnBeforeBrowse, or OnResourceRedirect). In the CefRequestHandler base class I see
Code: Select all
  virtual bool GetAuthCredentials(CefRefPtr<CefBrowser> browser,
                                  CefRefPtr<CefFrame> frame,
                                  bool isProxy,
                                  const CefString& host,
                                  int port,
                                  const CefString& realm,
                                  const CefString& scheme,
                                  CefRefPtr<CefAuthCallback> callback) {
    return false;
  }


But, the above method is not overridden in my code. I do not see any reference to CefAuthCallback neither. But, maybe in the base CefRequestHandler there is some reference kept to CefAuthCallback which causes that.

Re: Crash on closing the application

PostPosted: Tue Feb 26, 2019 10:17 am
by magreenblatt
I agree that call stack seems odd. You might want to check that you’re building against matching header/lib/binary/pdb files. It could also be some form of memory corruption in your app (use after free or unsafe cast to the wrong data type).

Re: Crash on closing the application

PostPosted: Sun Mar 03, 2019 8:56 am
by sikor
I cannot reproduce the problem and I have slightly modified the app.
SO, thanks for now. If it happens again, I will try to collect more data.