intermittent crash in CloseBrowser

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

intermittent crash in CloseBrowser

Postby robs » Thu Sep 06, 2018 3:33 pm

Sorry in advance for this not-great report. I fully expect this is user error but if someone has any hint from the call stack below I'd greatly appreciate it.

In my application I'm using offscreen rendering as well as the external message pump. Currently using CEF 3396.1779.

This crash happens on Windows when I'm closing things down and I call CefBrowserHost::CloseBrowser(true). So far I can reproduce regularly but only when I make two browser instances but the second is never actually made visible (but not understanding the crash it's hard to really know what the sufficient conditions are). I'm hoping that someone with a higher-level understanding of CEF might be able to guess why the "endpoint" in the below callstack could be nullptr?

Thanks for any ideas!

Rob

Debugger output window shows:
Exception thrown: read access violation.
**endpoint** was nullptr.


Callstack below:
Code: Select all
    libcef.dll!IPC::`anonymous namespace'::ChannelAssociatedGroupController::DetachEndpointClient(const mojo::ScopedInterfaceEndpointHandle & handle) Line 315   C++
    libcef.dll!mojo::InterfaceEndpointClient::~InterfaceEndpointClient() Line 173   C++
    libcef.dll!mojo::InterfaceEndpointClient::~InterfaceEndpointClient() Line 169   C++
    [Inline Frame] libcef.dll!std::default_delete<mojo::InterfaceEndpointClient>::operator()(mojo::InterfaceEndpointClient * _Ptr) Line 2127   C++
    [Inline Frame] libcef.dll!std::unique_ptr<mojo::InterfaceEndpointClient,std::default_delete<mojo::InterfaceEndpointClient> >::reset(mojo::InterfaceEndpointClient * _Ptr) Line 2376   C++
    libcef.dll!mojo::AssociatedBinding<content::mojom::RendererHost,mojo::RawPtrImplRefTraits<content::mojom::RendererHost> >::Unbind() Line 135   C++
    libcef.dll!content::RenderProcessHostImpl::ResetIPC() Line 3939   C++
    libcef.dll!content::RenderProcessHostImpl::Cleanup() Line 3257   C++
    libcef.dll!content::RenderWidgetHostImpl::Destroy(bool also_delete) Line 1962   C++
    libcef.dll!content::RenderViewHostImpl::ShutdownAndDestroy() Line 799   C++
    libcef.dll!content::FrameTree::ReleaseRenderViewHostRef(content::RenderViewHostImpl * render_view_host) Line 406   C++
    libcef.dll!content::RenderFrameHostImpl::~RenderFrameHostImpl() Line 680   C++
    libcef.dll!content::RenderFrameHostImpl::~RenderFrameHostImpl() Line 623   C++
    [Inline Frame] libcef.dll!std::default_delete<content::RenderFrameHostImpl>::operator()(content::RenderFrameHostImpl * _Ptr) Line 2127   C++
    [Inline Frame] libcef.dll!std::unique_ptr<content::RenderFrameHostImpl,std::default_delete<content::RenderFrameHostImpl> >::~unique_ptr() Line 2339   C++
    libcef.dll!content::RenderFrameHostManager::~RenderFrameHostManager() Line 87   C++
    libcef.dll!content::FrameTreeNode::~FrameTreeNode() Line 213   C++
    libcef.dll!content::FrameTree::~FrameTree() Line 119   C++
    libcef.dll!content::WebContentsImpl::~WebContentsImpl() Line 639   C++
    libcef.dll!content::WebContentsImpl::~WebContentsImpl() Line 545   C++
    [Inline Frame] libcef.dll!std::default_delete<content::WebContents>::operator()(content::WebContents * _Ptr) Line 2127   C++
    [Inline Frame] libcef.dll!std::unique_ptr<content::WebContents,std::default_delete<content::WebContents> >::reset(content::WebContents * _Ptr) Line 2376   C++
    libcef.dll!CefBrowserHostImpl::DestroyBrowser() Line 1551   C++
    libcef.dll!CefBrowserHostImpl::CloseContents(content::WebContents * source) Line 2272   C++
    libcef.dll!`anonymous namespace'::browser_host_close_browser(_cef_browser_host_t * self, int force_close) Line 130   C++
>   CefBrowserHostCToCpp::CloseBrowser(bool force_close) Line 93   C++
robs
Mentor
 
Posts: 70
Joined: Wed Jun 05, 2013 2:22 pm

Re: intermittent crash in CloseBrowser

Postby Czarek » Fri Sep 07, 2018 2:05 am

Does it reproduce in cefclient? There were some commits yesterday that fixed external message pump in latest branches.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: intermittent crash in CloseBrowser

Postby robs » Fri Sep 07, 2018 1:05 pm

Hi Czarek,

Thanks for the info on yesterday's commits. I'm not sure if they are relevant. I've scripted my application to continuously open and close browser windows every four seconds. In addition to the crash I'm seeing I also sometimes get deadlocks. Likely I have multiple issues that need to be resolved. To reproduce in the cefclient I probably have to script it in a similar way. I just might try that to make sure the issues I'm seeing are my own.

Thanks again,
Rob
robs
Mentor
 
Posts: 70
Joined: Wed Jun 05, 2013 2:22 pm

Re: intermittent crash in CloseBrowser

Postby robs » Tue Sep 11, 2018 3:58 pm

For the record, I found my problem. Reporting here in case it helps anyone else.

I'm using the external message pump. My implementation of CefBrowserProcessHandler::OnScheduleMessagePumpWork() was bad. If the delay_ms parameter was zero or negative then I was synchronously calling CefDoMessageLoopWork(). Changing this to so the call to CefDoMessageLoopWork() triggered from OnScheduleMessagePumpWork() is always async eliminated the crashes and hangs that I was seeing.

The cefclient MainMessageLoopExternalPumpWin::OnScheduleMessagePumpWork() does the right thing and always calls PostMessage() and thus is async. This triggers a call to MainMessageLoopExternalPump::OnScheduleWork() which will synchronously execute the work for zero and negative delay values. When I was reading through the cefclient code as an example I had missed the fact that there was a PostMessage() happening in between the call to OnScheduleMessagePumpWork() and OnScheduleWork().

In any case, I'm very happy to have figured this out. Hopefully this is goodbye to random stalls and crashes!
robs
Mentor
 
Posts: 70
Joined: Wed Jun 05, 2013 2:22 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 44 guests