Crash on shutdown

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.

Crash on shutdown

Postby digory » Mon Feb 20, 2017 2:56 am

I have successfully integrated CEF in our application. The only problem is that it crashes when the application is closed. This has been an issue for a while now, and since the demo application cef_client crashed as well, I always thought it was a bug of CEF itself. In fact, there is an issue describing the problem. https://bitbucket.org/chromiumembedded/ ... with-multi

Today I've updated CEF to the latest stable version (g558741c) and realized the demo application no longer crashes. However, when I tried it in our application, it would still crash. I begin to suspect something's amiss with my own code...

I've included a screenshot showing the stack trace, see attachments. Apparently, a singleton is being deleted, and there's a keyed service mapping that ought to be empty but isn't. Any ideas what's going on?
Attachments
crash.png
crash.png (52.75 KiB) Viewed 7718 times
digory
Expert
 
Posts: 118
Joined: Wed Oct 26, 2016 3:13 am

Re: Crash on shutdown

Postby digory » Mon Feb 20, 2017 5:47 am

Here's how CEF is initialized:

Code: Select all
int KisCefApp::initialize (HINSTANCE hinst)
   {
   int nExitCode = -1;
   DWORD dwThreadId = -1;

   ::CefEnableHighDPISupport();
   g_Singleton = new KisCefApp();
   ::CefMainArgs mainArgs (hinst);
   nExitCode = ::CefExecuteProcess (mainArgs, g_Singleton, NULL);
   if (nExitCode >= 0) { return nExitCode; }

   CefSettings settings;
   settings.command_line_args_disabled = true;
   settings.no_sandbox = true;
   settings.multi_threaded_message_loop = true;
   settings.persist_session_cookies = false;
   settings.persist_user_preferences = false;
   settings.background_color = CefColorSetARGB (0xff, 0xf0, 0xf0, 0xf0);
   settings.log_severity = LOGSEVERITY_INFO;

   PWSTR strLocalAppDataPath;
   HRESULT hres = ::SHGetKnownFolderPath (FOLDERID_LocalAppData, 0, NULL, &strLocalAppDataPath);

   if (hres == S_OK)
      {
      std::wstring strTmp = std::wstring (strLocalAppDataPath) + L"\\com.example.product\\cef_log";
      cef_string_utf16_set (strTmp.c_str(), strTmp.size(), &settings.log_file, true);  // true = clone

      strTmp = std::wstring (strLocalAppDataPath) + L"\\com.example.product\\cef_cache";
      cef_string_utf16_set (strTmp.c_str(), strTmp.size(), &settings.cache_path, true);  // true = clone

      strTmp = std::wstring (strLocalAppDataPath) + L"\\com.example.product\\cef_user_data";
      cef_string_utf16_set (strTmp.c_str(), strTmp.size(), &settings.user_data_path, true);  // true = clone
      }

   CefString strTmp = "com.example.product";
   cef_string_utf16_set (strTmp.c_str(), strTmp.size(), &settings.user_agent, true);  // true = clone

   strTmp = _getVersionString();
   cef_string_utf16_set (strTmp.c_str(), strTmp.size(), &settings.product_version, true);  // true = clone

   ::CefInitialize (mainArgs, settings, g_Singleton.get(), NULL);
   return nExitCode;
   }


Shutdown is simply a call to CefShutdown().
digory
Expert
 
Posts: 118
Joined: Wed Oct 26, 2016 3:13 am

Re: Crash on shutdown

Postby digory » Mon Feb 20, 2017 5:55 am

I realized the cefclient demo application crashes, too. I forgot to enable multi-threaded message loop. Add the following line after PopulateSettings in cefclient_win.cc:

Code: Select all
settings.multi_threaded_message_loop = true;


Start cefclient in debug mode, close it => crash!

When are you guys going to fix this? This is an issue to us!
digory
Expert
 
Posts: 118
Joined: Wed Oct 26, 2016 3:13 am

Re: Crash on shutdown

Postby digory » Mon Feb 20, 2017 8:45 am

Something's still odd, though. The cef_client app crashes only in debug mode; in release mode, it terminates gracefully without any complaint. On the other hand, our application crashes even in release mode. Any ideas why this might be the case? I've double-checked I'm using the Release libs in release mode.
digory
Expert
 
Posts: 118
Joined: Wed Oct 26, 2016 3:13 am

Re: Crash on shutdown

Postby magreenblatt » Mon Feb 20, 2017 3:04 pm

What is the symbolized call stack for the Release build crash of your app?
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Crash on shutdown

Postby digory » Tue Feb 21, 2017 11:09 am

Thanks for the reply. See the attached screenshot.
Attachments
crash2.png
crash2.png (119.46 KiB) Viewed 7685 times
digory
Expert
 
Posts: 118
Joined: Wed Oct 26, 2016 3:13 am

Re: Crash on shutdown

Postby magreenblatt » Tue Feb 21, 2017 12:14 pm

Are you using the CEF binary distribution with your application? If so, are you running with the Release build of libcef.dll?
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Crash on shutdown

Postby digory » Wed Feb 22, 2017 1:48 am

I'm using the binary distribution. I ran CMake, then opened ALL_BUILD.vcxproj and built both the Release and the Debug version. From my own project, I refer to chromium-embedded\Release\libcef.lib as shown in the screenshot above (the image can be scrolled).

I noticed libcef.lib is not regenerated when rebuilding ALL_BUILD.vcxproj. Is this normal? The timestamp is from Feb 16 08:03, so it seems to have come directly with the binary distribution.
digory
Expert
 
Posts: 118
Joined: Wed Oct 26, 2016 3:13 am

Re: Crash on shutdown

Postby magreenblatt » Wed Feb 22, 2017 12:53 pm

The libcef.lib and libcef.dll files are included in the binary distribution. Make sure you're copying the Release version of libcef.dll to sit next to your application executable.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Crash on shutdown

Postby digory » Thu Feb 23, 2017 1:58 am

Oops, you're right! My mistake. Thanks!
digory
Expert
 
Posts: 118
Joined: Wed Oct 26, 2016 3:13 am


Return to Support Forum

Who is online

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