Crashing when releasing proxy on IO thread

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.

Crashing when releasing proxy on IO thread

Postby emerick » Mon Jul 09, 2012 8:55 am

I recently upgraded my app to use the 1084 CEF1 release branch. Now when I run my app, it crashes whenever I close a browser window. Long story short, I noticed that the following line in browser_impl.cc seems to trigger the problem:

Code: Select all
  // Release the proxy on the IO thread.
  CefThread::ReleaseSoon(CefThread::IO, FROM_HERE,
      request_context_proxy_.release());


Looking at the trunk version of browser_impl.cc, I noticed that this code has been changed to:

Code: Select all
  // Delete the proxy on the IO thread.
  CefThread::DeleteSoon(CefThread::IO, FROM_HERE,
      request_context_proxy_.release());


When I changed my version of CEF to use DeleteSoon instead of ReleaseSoon, the crash went away. Is there a reason why CEF calls ReleaseSoon in the 1084 branch but DeleteSoon on the trunk? If the call to ReleaseSoon is actually important, is there something I'm doing wrong in my app to trigger this bad behavior? It doesn't seem to affect CefClient.
emerick
Expert
 
Posts: 154
Joined: Sun Feb 21, 2010 7:57 pm
Location: Belmont, MA

Re: Crashing when releasing proxy on IO thread

Postby emerick » Mon Jul 09, 2012 9:32 am

In digging into this a little bit more, it seems that calling ReleaseSoon is appropriate when request_context_proxy_ is NULL and calling DeleteSoon is appropriate when it's non-NULL. I could be barking up the wrong tree with this, though.
emerick
Expert
 
Posts: 154
Joined: Sun Feb 21, 2010 7:57 pm
Location: Belmont, MA

Re: Crashing when releasing proxy on IO thread

Postby Czarek » Mon Jul 09, 2012 9:52 am

I've also had errors recently when closing browser, a fix turned out to be to call PostMessage(WM_DESTROY) instead of DestroyWindow().

Marshall is on vacation:)
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: Crashing when releasing proxy on IO thread

Postby emerick » Mon Jul 09, 2012 9:57 am

Enjoy your well-deserved vacation, Marshall... :-)

I'll just use this workaround for now (which I'm sure is wrong, but it seems to be working for me):

Code: Select all
  if (request_context_proxy_) {
    CefThread::ReleaseSoon(CefThread::IO, FROM_HERE,
        request_context_proxy_.release());
  } else {
    CefThread::DeleteSoon(CefThread::IO, FROM_HERE,
        request_context_proxy_.release());
  }
emerick
Expert
 
Posts: 154
Joined: Sun Feb 21, 2010 7:57 pm
Location: Belmont, MA

Re: Crashing when releasing proxy on IO thread

Postby magreenblatt » Sat Jul 14, 2012 3:15 pm

emerick wrote:In digging into this a little bit more, it seems that calling ReleaseSoon is appropriate when request_context_proxy_ is NULL and calling DeleteSoon is appropriate when it's non-NULL. I could be barking up the wrong tree with this, though.

The object changed from scoped_refptr in older versions to scoped_ptr (non ref counted) in new versions. ReleaseSoon is for ref counted types and DeleteSoon is for non ref counted types. Likely DeleteSoon (which calls operator delete) is more forgiving of NULL pointers than ReleaseSoon. Neither should be called if the pointer is NULL. Please add an issue to the issue tracker.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Crashing when releasing proxy on IO thread

Postby emerick » Sun Jul 15, 2012 5:23 pm

Thanks for the information, Marshall. I entered a new bug in the issue tracker here: http://code.google.com/p/chromiumembedd ... ail?id=677
emerick
Expert
 
Posts: 154
Joined: Sun Feb 21, 2010 7:57 pm
Location: Belmont, MA


Return to Support Forum

Who is online

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