chromiumembedded / cef

Chromium Embedded Framework (CEF). A simple framework for embedding Chromium-based browsers in other applications.
https://bitbucket.org/chromiumembedded/cef/
Other
3.36k stars 467 forks source link

CEF3: NotificationRegistrar CalledOnValidThread() assertion during shutdown with multi-threaded message loop #755

Closed magreenblatt closed 12 years ago

magreenblatt commented 12 years ago

Original report by Anonymous.


Original issue 755 created by jeremie.rubinsztajn on 2012-10-11T15:35:18.000Z:

What steps will reproduce the problem?

  1. Launch CefClient in debug mode
  2. Load any page with Flash (such as http://www.youtube.com/watch?v=06\_uCl\_Bovs)
  3. Quit CefClient

What is the expected output? What do you see instead?
CefClient should quit without hitting any break point nor issuing any error.
CefClient hits two break points in CefShutdown() and the corresponding two error reports are logged.

What version of the product are you using? On what operating system?
CEF 8.1180.823 on Windows 7 32bits with VS2008

Please provide any additional information below.
Beside hitting the break points when in debug mode, I did not see any unwanted behavior.
However, I think it can't be good that the non-thread-safe NotificationRegistrar is called on a non-valid thread.

The two errors cited above:
[1010/172338:FATAL:notification_registrar.cc(79)] Check failed: CalledOnValidThread().
Backtrace:
cef_browser_host_create_browser [0x0F525B21+788825]
cef_browser_host_create_browser [0x0F51213F+708471]
cef_time_from_doublet [0x105FFAF9+16486105]
cef_time_from_doublet [0x105FF4A6+16484486]
cef_time_from_doublet [0x1083E646+18840102]
cef_time_from_doublet [0x1083E536+18839830]
cef_time_from_doublet [0x10844F1F+18866943]
cef_time_from_doublet [0x10843816+18861046]
cef_browser_host_create_browser [0x0F544137+913263]
cef_browser_host_create_browser [0x0F5440F8+913200]
cef_browser_host_create_browser [0x0F5440B5+913133]
cef_browser_host_create_browser [0x0F5427CF+906759]
cef_browser_host_create_browser [0x0F542465+905885]
cef_browser_host_create_browser [0x0F5420FA+905010]
cef_time_from_doublet [0x10582DE6+15974854]
cef_time_from_doublet [0x10582DA2+15974786]
cef_time_from_doublet [0x10582141+15971617]
cef_browser_host_create_browser [0x0F5BA7BD+1398261]
cef_browser_host_create_browser [0x0F5B9820+1394264]
cef_browser_host_create_browser [0x0F5B8979+1390513]
cef_browser_host_create_browser [0x0F4699B5+18413]
CefShutdown [0x013C09FC+12] (c:\users\jr250175\documents\projets\2012-03-28 - tcs connection client\etudes\chromium emdedded\cef_binary_3.1180.823_windows\libcef_dll\wrapper\libcef_dll_wrapper.cc:151)
wWinMain [0x0137661E+638] (c:\users\jr250175\documents\projets\2012-03-28 - tcs connection client\etudes\chromium emdedded\cef_binary_3.1180.823_windows\cefclient\cefclient_win.cpp:119)
__tmainCRTStartup [0x0140AD05+357] (f:\dd\vctools\crt_bld\self_x86\crt\src\crt0.c:263)
wWinMainCRTStartup [0x0140AB8F+15] (f:\dd\vctools\crt_bld\self_x86\crt\src\crt0.c:182)
BaseThreadInitThunk [0x76461114+18]
RtlInitializeExceptionChain [0x77B7B299+99]
RtlInitializeExceptionChain [0x77B7B26C+54]

[1010/172344:FATAL:non\_thread\_safe\_impl.cc(12)] Check failed: CalledOnValidThread().  
Backtrace:  
   cef\_browser\_host\_create\_browser [0x0F525B21+788825]  
   cef\_browser\_host\_create\_browser [0x0F51213F+708471]  
   DelayedLowerToken [0x10DB8D10+2050112]  
   cef\_string\_multimap\_free [0x0F5F7F46+78390]  
   cef\_time\_from\_doublet [0x105FF4B9+16484505]  
   cef\_time\_from\_doublet [0x1083E646+18840102]  
   cef\_time\_from\_doublet [0x1083E536+18839830]  
   cef\_time\_from\_doublet [0x10844F1F+18866943]  
   cef\_time\_from\_doublet [0x10843816+18861046]  
   cef\_browser\_host\_create\_browser [0x0F544137+913263]  
   cef\_browser\_host\_create\_browser [0x0F5440F8+913200]  
   cef\_browser\_host\_create\_browser [0x0F5440B5+913133]  
   cef\_browser\_host\_create\_browser [0x0F5427CF+906759]  
   cef\_browser\_host\_create\_browser [0x0F542465+905885]  
   cef\_browser\_host\_create\_browser [0x0F5420FA+905010]  
   cef\_time\_from\_doublet [0x10582DE6+15974854]  
   cef\_time\_from\_doublet [0x10582DA2+15974786]  
   cef\_time\_from\_doublet [0x10582141+15971617]  
   cef\_browser\_host\_create\_browser [0x0F5BA7BD+1398261]  
   cef\_browser\_host\_create\_browser [0x0F5B9820+1394264]  
   cef\_browser\_host\_create\_browser [0x0F5B8979+1390513]  
   cef\_browser\_host\_create\_browser [0x0F4699B5+18413]  
   CefShutdown [0x013C09FC+12] (c:\\users\\jr250175\\documents\\projets\\2012-03-28 - tcs connection client\\etudes\\chromium emdedded\\cef\_binary\_3.1180.823\_windows\\libcef\_dll\\wrapper\\libcef\_dll\_wrapper.cc:151)  
   wWinMain [0x0137661E+638] (c:\\users\\jr250175\\documents\\projets\\2012-03-28 - tcs connection client\\etudes\\chromium emdedded\\cef\_binary\_3.1180.823\_windows\\cefclient\\cefclient\_win.cpp:119)  
   \_\_tmainCRTStartup [0x0140AD05+357] (f:\\dd\\vctools\\crt\_bld\\self\_x86\\crt\\src\\crt0.c:263)  
   wWinMainCRTStartup [0x0140AB8F+15] (f:\\dd\\vctools\\crt\_bld\\self\_x86\\crt\\src\\crt0.c:182)  
   BaseThreadInitThunk [0x76461114+18]  
   RtlInitializeExceptionChain [0x77B7B299+99]  
   RtlInitializeExceptionChain [0x77B7B26C+54]
magreenblatt commented 12 years ago

Comment 1. originally posted by magreenblatt on 2012-10-11T15:38:18.000Z:

Original forum post: http://magpcss.org/ceforum/viewtopic.php?f=6&t=4859

You mention in the forum post that you're using --multi-threaded-message-loop. Is this setting required to get the above error?

magreenblatt commented 12 years ago

Original comment by Anonymous.


Comment 2. originally posted by jeremie.rubinsztajn on 2012-10-11T15:41:09.000Z:

Yes sorry, the error happens when the application is launched with --multi-threaded-message-loop flag (i.e. CEF is configured with multi-threaded-message-loop = true)

magreenblatt commented 11 years ago

Original comment by Anonymous.


Comment 3. originally posted by jmayhew@google.com on 2013-02-21T23:35:39.000Z:

I am now seeing this as well. This happens on Win with multi-threaded-message-loop set to true.
It happens for me if I load a page via http (i.e. http://mydomain/mytest.htm) that contains an image with a src attribute that specifies the https protocol (i.e. ). When I load that page then quit CEF, I get an assert in the same spot. An excerpt of the stack trace is below.

[0221/153120:FATAL:notification_registrar.cc(79)] Check failed: CalledOnValidThread().
Backtrace:
base::debug::StackTrace::StackTrace [0x0F8B1B61+33] (c:\src\chromium\src\base\debug\stack_trace_win.cc:171)
logging::LogMessage::~LogMessage [0x0F89DF9F+63] (c:\src\chromium\src\base\logging.cc:565)
content::NotificationRegistrar::RemoveAll [0x10B7B939+153] (c:\src\chromium\src\content\public\browser\notification_registrar.cc:86)
content::NotificationRegistrar::~NotificationRegistrar [0x10B7B2E6+22] (c:\src\chromium\src\content\public\browser\notification_registrar.cc:42)
content::CertStoreImpl::~CertStoreImpl [0x10DD6ED6+102] (c:\src\chromium\src\content\browser\cert_store_impl.cc:53)
content::CertStoreImpl::`scalar deleting destructor' [0x10DD6DC6+22]
DefaultSingletonTraits::Delete [0x10DDD7AF+63] (c:\src\chromium\src\base\memory\singleton.h:59)
Singleton<content::CertStoreImpl,DefaultSingletonTraits,content::CertStoreImpl>::OnExit [0x10DDC0A6+22] (c:\src\chromium\src\base\memory\singleton.h:275)

magreenblatt commented 11 years ago

Comment 4. originally posted by magreenblatt on 2013-02-21T23:40:46.000Z:

@ comment 3.: Can you post the complete stack trace as an attachment? Thanks.

magreenblatt commented 11 years ago

Original comment by Anonymous.


Comment 6. originally posted by jmayhew@google.com on 2013-02-22T00:54:51.000Z:

here is a copy of the stack trace

magreenblatt commented 11 years ago

Comment 7. originally posted by magreenblatt on 2013-03-08T21:56:30.000Z:

This assertion occurs consistently when using "multi-threaded-message-loop" if you exit the application during active network traffic. For example, run cefclient with the following flags and then exit the application:

--multi-threaded-message-loop --enable-media-stream --url=http://apprtc.appspot.com/

magreenblatt commented 11 years ago

Comment 8. originally posted by magreenblatt on 2013-04-05T18:25:36.000Z:

The problem is that CertStoreImpl is a singleton and it owns a NotificationRegistrar instance. Singletons are destroyed by AtExitManager on the main application thread. NotificationRegistrar, on the other hand, needs to be destroyed on the UI thread. With multi-threaded message loop mode these are not the same thread and this leads to the assertion when the NotificationRegistrar is destroyed.

magreenblatt commented 11 years ago

Comment 9. originally posted by magreenblatt on 2013-04-05T18:44:41.000Z:

Filed with Chromium as https://code.google.com/p/chromium/issues/detail?id=227100. We'll see what solution they recommend.

magreenblatt commented 11 years ago

Original comment by Anonymous.


Comment 10. originally posted by sorejs on 2013-08-26T13:53:04.000Z:

Hi
any news on this? We have an app built arround latest cef3 id we ran into this issue. I am even ready to look into this, but need some clues on where and how to start.
Thanks

magreenblatt commented 10 years ago

Comment 11. originally posted by magreenblatt on 2013-12-19T18:04:56.000Z:

issue #1158 has been merged into this issue.

magreenblatt commented 10 years ago

Original comment by Anonymous.


Comment 12. originally posted by justin.romaine on 2014-01-20T05:51:57.000Z:

Same issue when calling multi-threaded-message-loop=true;

Here is the code change to the client sample and part of the debug.log contents.
AppGetSettings(settings);
settings.multi_threaded_message_loop = true;
settings.log_severity = LOGSEVERITY_ERROR;
This happends exit causing the application to crash/hang. Process never exists.

[0120/184635:FATAL:context.cc(178)] Check failed: false. called on invalid thread
Backtrace:
cef_time_delta [0x015C16F1+1906865]
cef_time_delta [0x0151957F+1218367]
cef_browser_host_create_browser [0x0132EF17+693221]
cef_browser_host_create_browser [0x0128D058+29990]
CefQuitMessageLoop [0x010DB08C+12] (d:\src\cef\libcef_dll\wrapper\libcef_dll_wrapper.cc:259)
AppQuitMessageLoop [0x0107FB26+182] (d:\src\cef\cefclient\cefclient_win.cpp:671)
ClientHandler::OnBeforeClose [0x010C5D3E+734] (d:\src\cef\cefclient\client_handler.cpp:384)
life_span_handler_on_before_close [0x01105B9C+156] (d:\src\cef\libcef_dll\cpptoc\life_span_handler_cpptoc.cc:191)
cef_browser_host_create_browser [0x012EDBF5+426179]
cef_string_multimap_free [0x0137E2E7+69751]
cef_string_multimap_free [0x01380BCF+80223]
cef_string_multimap_free [0x0137A24E+53214]
cef_string_multimap_free [0x0137E16B+69371]
cef_time_delta [0x014231BC+209788]
gapfnScSendMessage [0x765A62FA+818]
GetThreadDesktop [0x765A6D3A+215]
GetThreadDesktop [0x765A6DE8+389]
GetThreadDesktop [0x765A6E44+481]
KiUserCallbackDispatcher [0x7748010A+46]
PeekMessageW [0x765B0751+407]
cef_time_delta [0x015C405B+1917467]
cef_time_delta [0x015C4EA4+1921124]
cef_time_delta [0x015C47F1+1919409]
cef_time_delta [0x015C3CC2+1916546]
cef_time_delta [0x015C3F7C+1917244]
cef_time_delta [0x01522367+1254695]
cef_time_delta [0x0152213E+1254142]
cef_time_delta [0x01592C59+1715737]
cef_time_delta [0x0152198B+1252171]
cef_time_delta [0x01591E66+1712166]
cef_time_delta [0x015920AB+1712747]
cef_time_delta [0x01538291+1344593]
BaseThreadInitThunk [0x76AF336A+18]
RtlInitializeExceptionChain [0x774A9F72+99]
RtlInitializeExceptionChain [0x774A9F45+54]

magreenblatt commented 10 years ago

Comment 13. originally posted by magreenblatt on 2014-02-10T18:59:33.000Z:

Another related debug assertion from trunk revision 1610:

[0210/134206:FATAL:notification_registrar.cc(76)] Check failed: CalledOnValidThread().
Backtrace:
base::debug::StackTrace::StackTrace [0x1045DBF1+33] (c:\code\chromium_writable\src\base\debug\stack_trace_win.cc:207)
logging::LogMessage::~LogMessage [0x103AD7EF+63] (c:\code\chromium_writable\src\base\logging.cc:574)
content::NotificationRegistrar::RemoveAll [0x1050C4D9+153] (c:\code\chromium_writable\src\content\public\browser\notification_registrar.cc:83)
content::NotificationRegistrar::~NotificationRegistrar [0x1050BB06+22] (c:\code\chromium_writable\src\content\public\browser\notification_registrar.cc:42)
content::WebRTCInternals::~WebRTCInternals [0x1080663E+94] (c:\code\chromium_writable\src\content\browser\media\webrtc_internals.cc:66)
content::WebRTCInternals::`scalar deleting destructor' [0x10806DA6+22]
DefaultSingletonTraits::Delete [0x1080735F+63] (c:\code\chromium_writable\src\base\memory\singleton.h:59)
Singleton<content::WebRTCInternals,DefaultSingletonTraits,content::WebRTCInternals>::OnExit [0x10807ED6+22] (c:\code\chromium_writable\src\base\memory\singleton.h:275)
base::internal::RunnableAdapter<void (__cdecl*)(void *)>::Run [0x1044D157+39] (c:\code\chromium_writable\src\base\bind_internal.h:171)
base::internal::InvokeHelper<0,void,base::internal::RunnableAdapter<void (__cdecl*)(void *)>,void __cdecl(void * const &)>::MakeItSo [0x1044CD58+24] (c:\code\chromium_writable\src\base\bind_internal.h:872)
base::internal::Invoker<1,base::internal::BindState<base::internal::RunnableAdapter<void (__cdecl*)(void *)>,void __cdecl(void *),void __cdecl(void *)>,void __cdecl(void *)>::Run [0x1044D115+69] (c:\code\chromium_writable\src\base\bind_internal.h:1169)
base::Callback<void __cdecl(void)>::Run [0x103150BF+47] (c:\code\chromium_writable\src\base\callback.h:401)
base::AtExitManager::ProcessCallbacksNow [0x1044CE55+229] (c:\code\chromium_writable\src\base\at_exit.cc:73)
base::AtExitManager::~AtExitManager [0x1044CA9A+266] (c:\code\chromium_writable\src\base\at_exit.cc:41)
base::AtExitManager::`scalar deleting destructor' [0x142ED246+22]
base::DefaultDeleter::operator() [0x142ED186+54] (c:\code\chromium_writable\src\base\memory\scoped_ptr.h:137)
base::internal::scoped_ptr_impl<base::AtExitManager,base::DefaultDeleter >::reset [0x142EFB5F+79] (c:\code\chromium_writable\src\base\memory\scoped_ptr.h:247)
scoped_ptr<base::AtExitManager,base::DefaultDeleter >::reset [0x142EFAFA+26] (c:\code\chromium_writable\src\base\memory\scoped_ptr.h:367)
content::ContentMainRunnerImpl::Shutdown [0x142EF6B1+417] (c:\code\chromium_writable\src\content\app\content_main_runner.cc:824)
CefContext::FinalizeShutdown [0x101E2165+101] (c:\code\chromium_writable\src\cef\libcef\browser\context.cc:404)
CefContext::Shutdown [0x101E31D2+322] (c:\code\chromium_writable\src\cef\libcef\browser\context.cc:326)
CefShutdown [0x101E2055+357] (c:\code\chromium_writable\src\cef\libcef\browser\context.cc:147)
cef_shutdown [0x1013F575+37] (c:\code\chromium_writable\src\cef\libcef_dll\libcef_dll.cc:179)
CefShutdown [0x00461FBC+12] (c:\code\chromium_writable\src\cef\libcef_dll\wrapper\libcef_dll_wrapper.cc:167)
wWinMain [0x00459E37+887] (c:\code\chromium_writable\src\cef\tests\cefclient\cefclient_win.cpp:171)
__tmainCRTStartup [0x0068A8B8+296] (f:\dd\vctools\crt\crtw32\startup\crt0.c:251)
wWinMainCRTStartup [0x0068A9FD+13] (f:\dd\vctools\crt\crtw32\startup\crt0.c:165)
BaseThreadInitThunk [0x75C3850D+14]
RtlInitializeExceptionChain [0x778DBF39+133]
RtlInitializeExceptionChain [0x778DBF0C+88]

magreenblatt commented 10 years ago

Comment 14. originally posted by magreenblatt on 2014-09-18T19:12:03.000Z:

Fixed in trunk revision 1837, 2062 branch revision 1838 and 1916 branch revision 1839.

magreenblatt commented 10 years ago

Comment 15. originally posted by magreenblatt on 2014-09-18T19:40:35.000Z:

@ comment 14.: Filed with Chromium as https://codereview.chromium.org/575283004/

magreenblatt commented 11 years ago

Original changes by Anonymous.


magreenblatt commented 11 years ago
magreenblatt commented 10 years ago