Check failed: !IsCefShutdown(). Object reference incorrectly

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.

Check failed: !IsCefShutdown(). Object reference incorrectly

Postby rdh » Wed Jul 01, 2020 3:54 pm

Any chance I can get this output message to show the actual pointer value(s)?
rdh
Techie
 
Posts: 33
Joined: Wed Jun 10, 2020 3:18 pm

Re: Check failed: !IsCefShutdown(). Object reference incorre

Postby Czarek » Wed Jul 01, 2020 4:41 pm

You have to use debugger and see stack trace. You can obtain release/debug symbols from where you've downloaded CEF distrib.
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: Check failed: !IsCefShutdown(). Object reference incorre

Postby rdh » Tue Jul 07, 2020 9:53 am

I grabbed the symbols. I set an action based breakpoint in my client handler's OnAfterCreated method and wrote out the input browser pointer. Here is the call stack when I crash:

libcef.dll!logging::LogMessage::~LogMessage() Line 953 C++
libcef.dll!cef_log(const char * file, int line, int severity, const char * message=0x00000000445828f0) Line 335 C++
> jengined.dll!cef::logging::LogMessage::~LogMessage() Line 186 C++
jengined.dll!shutdown_checker::AssertNotShutdown() Line 54 C++
jengined.dll!`anonymous namespace'::life_span_handler_on_before_close(_cef_life_span_handler_t * self=0x000000001b9a73c0, _cef_browser_t * browser=0x0000000088feb770) Line 198 C++
libcef.dll!CefAudioHandlerCToCpp::OnAudioStreamStopped(scoped_refptr<CefBrowser> browser={...}) Line 113 C++
libcef.dll!CefBrowserHostImpl::DestroyBrowser() Line 1583 C++
libcef.dll!CefBrowserInfoManager::DestroyAllBrowsers() Line 352 C++
libcef.dll!CefContext::FinishShutdownOnUIThread(base::WaitableEvent * uithread_shutdown_event=0x0000000000dfdb50) Line 680 C++

Note the life_span_handler_on_before_close shows me the browser pointer is 0x88feb770. Meanwhile in the output window the action breakpoints show this:

ClientHandler browser is {ptr_=0x000000000ede3940 {...} }
ClientHandler browser is {ptr_=0x000000000ede36c0 {...} }
ClientHandler browser is {ptr_=0x000000001b79f050 {...} }

I have three windows in my app hosting CEF and none of the browsers passed to me match the one on the call stack. So, I still have not determined why cef is randomely crashing my process during shutdown.

Edit update ...
I changed the output to use the result of GetIdentifier after noticing that the input pointer to the methods is of type CefBrowserToCpp. I'm thinking the wrapper stuff is hiding the "real" browser pointer from me making comparing the pointers passed into the methods and the one on the call stack when I crash useless. Now I see that in the current crash, I have IDs of 1, 2 and 3. DoClose is called for 1 and 2 but not 3. And, OnBeforeClose is only called for 3. So, what would be useful in the cef output is the actual browser ID. Something like "Object reference incorrectly held at CefShutdown for browser ID 1"
Last edited by rdh on Tue Jul 07, 2020 10:20 am, edited 1 time in total.
rdh
Techie
 
Posts: 33
Joined: Wed Jun 10, 2020 3:18 pm

Re: Check failed: !IsCefShutdown(). Object reference incorre

Postby magreenblatt » Tue Jul 07, 2020 10:00 am

The pointers are not expected to match. You need to wait for OnBeforeClose and release all CefRefPtr<CefBrowser> before shutting down.
magreenblatt
Site Admin
 
Posts: 12383
Joined: Fri May 29, 2009 6:57 pm

Re: Check failed: !IsCefShutdown(). Object reference incorre

Postby rdh » Tue Jul 07, 2020 10:45 am

Hi magreenblat,

Thanks, I got that. I'm trying to figure out how long to wait before I give up. Currently I wait 10 seconds and I do sometimes see the other browsers close while I am waiting. But, I set the wait to infinite and that was a failure - I sometimes never shut down as I never get the call that one of the browsers is closed. Sometimes one doesn't close, sometimes two of them don't get closed and sometimes they all get closed (most of the time, actually). At least I can tell which one isn't closing now which gives me a chance to figure out why it isn't closing. I think it has to have something to do with the window parenting I have going on and the bottom-up window destruction the OS uses.
rdh
Techie
 
Posts: 33
Joined: Wed Jun 10, 2020 3:18 pm

Re: Check failed: !IsCefShutdown(). Object reference incorre

Postby Czarek » Tue Jul 07, 2020 11:48 am

How are you running message looP?
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: Check failed: !IsCefShutdown(). Object reference incorre

Postby rdh » Tue Jul 07, 2020 4:00 pm

Czarek,

I have a classic windows application and we do the standard pretranslate and dispatch for the application. We are not a browser by any means. So, I just call CefExecuteProcess with a CefMainArgs (no hInstance passed as my app has nothing it can contribute via that). Then I call CefInitialize and return back to the caller. The caller is one of our windows that hosts a browser. To make it worse, the shutdown code for a Windows window that I found in a cef include file all starts with "When the user hits the x button" (paraphrasing) or the window, which doesn't happen in my case. These are not "free" floating dialogs where the user has a close button. The OS is tearing down the windows as the application exits, which I think is part of my problem - the cef child window will be destroyed before the parent window as they are all child windows of the app mainframe window.

So far, I can only get one browser to be passed to the OnBeforeClose method though I see every one of them come thru DoClose where I always return false. Right now I have 3 windows all constructed the same way and only one of them is getting the OnBeforeClose call. I am running our app in debug but linking to the release ceflib.lib. I only link with a wrapper debug lib when building debug. That should not matter though. I am right now working to get into the window destruction as soon as I can to see if an earlier call to close the browser can fix the issue. Why one works and the other two don't is a mystery. Where is Jonathan Creek when you need him?
rdh
Techie
 
Posts: 33
Joined: Wed Jun 10, 2020 3:18 pm

Re: Check failed: !IsCefShutdown(). Object reference incorre

Postby Czarek » Tue Jul 07, 2020 5:27 pm

I mean how do you run CEF message loop? When closing browsers and exiting app you need to run CEF message loop for some time, so it can process closing browsers. You must run message loop until OnBeforeClose is called and only then it is safe to close app.
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


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 40 guests