capi cef_shutdown cause a breakpoint exception on windows

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.

capi cef_shutdown cause a breakpoint exception on windows

Postby iwatsurut » Mon May 24, 2021 7:59 am

Capi cef_shutdown cause a breakpoint exception on windows.

I have reproduced the problem with https://github.com/turutcrane/cefcapi-simple-win.

This repository is a Visual Studio 2019 solution build with capi code of https://github.com/cztomczak/cefcapi.

With libraries in the Release directory of the spotify build cef_binary_88.2.9+g5c8711a+chromium-88.0.4324.182_windows64,
this solution work fine.

But with libraries in the Release directory of the cef_binary_89.0.18+gb36241d+chromium-89.0.4389.114_windows64.tar.bz2,
this solution cause a breakpoint excepition in cef_shutdown on clicking the close window button.

Stack trace of Chrome_IOThread is here
Code: Select all
Not Flagged   >   348   0   Worker Thread   Chrome_IOThread   libcef.dll!base::SequencedTaskRunnerHandle::Get
        libcef.dll!base::SequencedTaskRunnerHandle::Get() Line 26
        [Inline Frame] libcef.dll!storage::`anonymous namespace'::MakeDeferredDeleter(std::__1::unique_ptr<storage::LocalStorageImpl,std::default_delete<storage::LocalStorageImpl>> object) Line 29
        [Inline Frame] libcef.dll!storage::`anonymous namespace'::ShutDown(std::__1::unique_ptr<storage::LocalStorageImpl,std::default_delete<storage::LocalStorageImpl>> object) Line 44
        libcef.dll!storage::PartitionImpl::~PartitionImpl() Line 57
        libcef.dll!storage::PartitionImpl::~PartitionImpl() Line 56
        [Inline Frame] libcef.dll!std::__1::default_delete<content::OneShotBackgroundSyncServiceImpl>::operator()(content::OneShotBackgroundSyncServiceImpl * __ptr) Line 2378
        [Inline Frame] libcef.dll!std::__1::unique_ptr<content::OneShotBackgroundSyncServiceImpl,std::default_delete<content::OneShotBackgroundSyncServiceImpl>>::reset(content::OneShotBackgroundSyncServiceImpl * __p) Line 2633
        [Inline Frame] libcef.dll!std::__1::unique_ptr<content::OneShotBackgroundSyncServiceImpl,std::default_delete<content::OneShotBackgroundSyncServiceImpl>>::~unique_ptr() Line 2587
        [Inline Frame] libcef.dll!std::__1::allocator_traits<std::allocator<std::__tree_node<std::unique_ptr<content::OneShotBackgroundSyncServiceImpl,std::default_delete<content::OneShotBackgroundSyncServiceImpl>>,void *>>>::__destroy(std::__1::integral_constant<bool,0>, std::__1::allocator<std::__tree_node<std::unique_ptr<content::OneShotBackgroundSyncServiceImpl,std::default_delete<content::OneShotBackgroundSyncServiceImpl>>,void *>> &, std::__1::unique_ptr<content::OneShotBackgroundSyncServiceImpl,std::default_delete<content::OneShotBackgroundSyncServiceImpl>> * __p) Line 1787
        [Inline Frame] libcef.dll!std::__1::allocator_traits<std::allocator<std::__tree_node<std::unique_ptr<content::OneShotBackgroundSyncServiceImpl,std::default_delete<content::OneShotBackgroundSyncServiceImpl>>,void *>>>::destroy(std::__1::allocator<std::__tree_node<std::unique_ptr<content::OneShotBackgroundSyncServiceImpl,std::default_delete<content::OneShotBackgroundSyncServiceImpl>>,void *>> & __a, std::__1::unique_ptr<content::OneShotBackgroundSyncServiceImpl,std::default_delete<content::OneShotBackgroundSyncServiceImpl>> * __p) Line 1619
        libcef.dll!std::__1::__tree<std::unique_ptr<content::OneShotBackgroundSyncServiceImpl,std::default_delete<content::OneShotBackgroundSyncServiceImpl>>,base::UniquePtrComparator,std::allocator<std::unique_ptr<content::OneShotBackgroundSyncServiceImpl,std::default_delete<content::OneShotBackgroundSyncServiceImpl>>>>::destroy(std::__1::__tree_node<std::unique_ptr<content::OneShotBackgroundSyncServiceImpl,std::default_delete<content::OneShotBackgroundSyncServiceImpl>>,void *> * __nd) Line 1834
        [Inline Frame] libcef.dll!std::__1::__tree<std::unique_ptr<storage::PartitionImpl,std::default_delete<storage::PartitionImpl>>,base::UniquePtrComparator,std::allocator<std::unique_ptr<storage::PartitionImpl,std::default_delete<storage::PartitionImpl>>>>::~__tree() Line 1821
        [Inline Frame] libcef.dll!std::__1::set<std::unique_ptr<storage::PartitionImpl,std::default_delete<storage::PartitionImpl>>,base::UniquePtrComparator,std::allocator<std::unique_ptr<storage::PartitionImpl,std::default_delete<storage::PartitionImpl>>>>::~set() Line 603
        libcef.dll!storage::StorageServiceImpl::~StorageServiceImpl() Line 58
        libcef.dll!storage::StorageServiceImpl::~StorageServiceImpl() Line 58
        [Inline Frame] libcef.dll!std::__1::default_delete<device::DeviceService>::operator()(device::DeviceService * __ptr) Line 2378
        [Inline Frame] libcef.dll!std::__1::unique_ptr<device::DeviceService,std::default_delete<device::DeviceService>>::reset(device::DeviceService * __p) Line 2633
        [Inline Frame] libcef.dll!std::__1::unique_ptr<device::DeviceService,std::default_delete<device::DeviceService>>::~unique_ptr() Line 2587
        libcef.dll!std::__1::default_delete<std::unique_ptr<device::DeviceService,std::default_delete<device::DeviceService>>>::operator()(std::__1::unique_ptr<device::DeviceService,std::default_delete<device::DeviceService>> * __ptr) Line 2378
        [Inline Frame] libcef.dll!base::SequenceLocalStorageSlot<std::unique_ptr<device::DeviceService,std::default_delete<device::DeviceService>>,std::default_delete<std::unique_ptr<device::DeviceService,std::default_delete<device::DeviceService>>>>::Adopt::<unnamed-tag>::operator()(void * ptr) Line 110
        libcef.dll!base::SequenceLocalStorageSlot<std::unique_ptr<device::DeviceService,std::default_delete<device::DeviceService>>,std::default_delete<std::unique_ptr<device::DeviceService,std::default_delete<device::DeviceService>>>>::Adopt::<unnamed-tag>::__invoke(void * ptr) Line 110
        [Inline Frame] libcef.dll!base::internal::SequenceLocalStorageMap::ValueDestructorPair::~ValueDestructorPair() Line 79
        [Inline Frame] libcef.dll!std::__1::pair<int,base::internal::SequenceLocalStorageMap::ValueDestructorPair>::~pair() Line 297
        [Inline Frame] libcef.dll!std::__1::allocator<std::pair<int,base::internal::SequenceLocalStorageMap::ValueDestructorPair>>::destroy(std::__1::pair<int,base::internal::SequenceLocalStorageMap::ValueDestructorPair> * __p) Line 1920
        [Inline Frame] libcef.dll!std::__1::allocator_traits<std::allocator<std::pair<int,base::internal::SequenceLocalStorageMap::ValueDestructorPair>>>::__destroy(std::__1::integral_constant<bool,1>, std::__1::allocator<std::pair<int,base::internal::SequenceLocalStorageMap::ValueDestructorPair>> & __a, std::__1::pair<int,base::internal::SequenceLocalStorageMap::ValueDestructorPair> * __p) Line 1782
        [Inline Frame] libcef.dll!std::__1::allocator_traits<std::allocator<std::pair<int,base::internal::SequenceLocalStorageMap::ValueDestructorPair>>>::destroy(std::__1::allocator<std::pair<int,base::internal::SequenceLocalStorageMap::ValueDestructorPair>> & __a, std::__1::pair<int,base::internal::SequenceLocalStorageMap::ValueDestructorPair> * __p) Line 1619
        [Inline Frame] libcef.dll!std::__1::__vector_base<std::pair<int,base::internal::SequenceLocalStorageMap::ValueDestructorPair>,std::allocator<std::pair<int,base::internal::SequenceLocalStorageMap::ValueDestructorPair>>>::__destruct_at_end(std::__1::pair<int,base::internal::SequenceLocalStorageMap::ValueDestructorPair> * __new_last) Line 426
        [Inline Frame] libcef.dll!std::__1::__vector_base<std::pair<int,base::internal::SequenceLocalStorageMap::ValueDestructorPair>,std::allocator<std::pair<int,base::internal::SequenceLocalStorageMap::ValueDestructorPair>>>::clear() Line 369
        [Inline Frame] libcef.dll!std::__1::__vector_base<std::pair<int,base::internal::SequenceLocalStorageMap::ValueDestructorPair>,std::allocator<std::pair<int,base::internal::SequenceLocalStorageMap::ValueDestructorPair>>>::~__vector_base() Line 463
        [Inline Frame] libcef.dll!std::__1::vector<std::pair<int,base::internal::SequenceLocalStorageMap::ValueDestructorPair>,std::allocator<std::pair<int,base::internal::SequenceLocalStorageMap::ValueDestructorPair>>>::~vector() Line 555
        [Inline Frame] libcef.dll!base::internal::flat_tree<int,base::internal::GetFirst,std::less<void>,std::vector<std::pair<int,base::internal::SequenceLocalStorageMap::ValueDestructorPair>,std::allocator<std::pair<int,base::internal::SequenceLocalStorageMap::ValueDestructorPair>>>>::~flat_tree() Line 222
        libcef.dll!base::internal::SequenceLocalStorageMap::~SequenceLocalStorageMap() Line 23
        libcef.dll!base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::~ThreadControllerWithMessagePumpImpl() Line 61
        libcef.dll!base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::~ThreadControllerWithMessagePumpImpl() Line 56
        [Inline Frame] libcef.dll!std::__1::default_delete<base::sequence_manager::internal::ThreadController>::operator()(base::sequence_manager::internal::ThreadController * __ptr) Line 2378
        [Inline Frame] libcef.dll!std::__1::unique_ptr<base::sequence_manager::internal::ThreadController,std::default_delete<base::sequence_manager::internal::ThreadController>>::reset(base::sequence_manager::internal::ThreadController * __p) Line 2633
        [Inline Frame] libcef.dll!std::__1::unique_ptr<base::sequence_manager::internal::ThreadController,std::default_delete<base::sequence_manager::internal::ThreadController>>::~unique_ptr() Line 2587
        libcef.dll!base::sequence_manager::internal::SequenceManagerImpl::~SequenceManagerImpl() Line 258
        libcef.dll!base::sequence_manager::internal::SequenceManagerImpl::~SequenceManagerImpl() Line 212
        libcef.dll!content::BrowserIOThreadDelegate::~BrowserIOThreadDelegate() Line 92
        [Inline Frame] libcef.dll!std::__1::default_delete<base::Thread::Delegate>::operator()(base::Thread::Delegate * __ptr) Line 2378
        [Inline Frame] libcef.dll!std::__1::unique_ptr<base::Thread::Delegate,std::default_delete<base::Thread::Delegate>>::reset(base::Thread::Delegate * __p) Line 2633
        libcef.dll!base::Thread::ThreadMain() Line 401
        libcef.dll!base::`anonymous namespace'::ThreadFunc(void * params) Line 103
        [External Code]



And with libraries in the Debug directory of recent builds, when the close window button, a breakpoint exception has triggerd in cef_shutdown with the following message.
Code: Select all
[0519/214655.818:FATAL:alloy_browser_main.cc(221)] Check failed: global_request_context_->HasOneRef().
cefcapi-simple.exe has triggered a breakpoint.
iwatsurut
Newbie
 
Posts: 4
Joined: Wed Jan 08, 2020 9:45 pm

Re: capi cef_shutdown cause a breakpoint exception on window

Postby gagere » Mon Jul 12, 2021 11:23 am

Just bumping this up. This still occurs in 91 and leaves a dmp file on every shutdown of our application.
gagere
Newbie
 
Posts: 6
Joined: Tue Oct 08, 2013 8:30 pm

Re: capi cef_shutdown cause a breakpoint exception on window

Postby iwatsurut » Wed Aug 04, 2021 7:39 am

I found my codes have bugs.
Those do not confirm the capi Reference Counting Rule (3.).

Adding
Code: Select all
    browser->base.release((_cef_base_ref_counted_t*)browser);

to on_before_close callback of _cef_life_span_handler_t* eliminates the problem.

But, I do not know why this code fix eliminates the problem.
Any information about reason are appreciated.

Thanks,
iwatsurut
Newbie
 
Posts: 4
Joined: Wed Jan 08, 2020 9:45 pm

Re: capi cef_shutdown cause a breakpoint exception on window

Postby Serg345 » Tue Nov 02, 2021 9:53 am

I have crashes with the same stack trace. The application is cefclient.exe from here: https://cef-builds.spotifycdn.com/index.html. Occurs on versions 89 - 94.
Serg345
Newbie
 
Posts: 1
Joined: Tue Nov 02, 2021 9:18 am

Re: capi cef_shutdown cause a breakpoint exception on window

Postby DavidK71 » Sun Nov 07, 2021 3:31 pm

I have been seeing this crash, too. In my case I tracked it down to needing to make sure that CEF message processing was called before shutting down CEF, as I am not using the multi-threading messaging loop. Adding a loop to call CefDoMessageLoopWork() several times immediately before calling CefShutdown() has made the crash go away for me.

That this fixed the problem for me suggests that it's important to make sure there aren't pending messages for CEF waiting to be processed before shutting down, which doesn't seem unreasonable.
DavidK71
Newbie
 
Posts: 2
Joined: Sun Nov 07, 2021 3:25 pm

Re: capi cef_shutdown cause a breakpoint exception on window

Postby dprovinciani » Mon Nov 29, 2021 2:09 am

I'm experiencing the same issue in my project. I initially saw this after upgrading to CEF 89, and then I tried with CEF 90 and 91 without having success.

Also, I implemented the suggested changes and the crash is still happening:
- Adding a loop to call CefDoMessageLoopWork() several times immediately before calling CefShutdown()
- Releasing the browser within on_before_close callback

I see that some of you got this crash even with CEF 94. Did anyone try with a newer version?
dprovinciani
Newbie
 
Posts: 1
Joined: Mon Oct 11, 2021 11:40 pm

Re: capi cef_shutdown cause a breakpoint exception on window

Postby DavidK71 » Tue Dec 07, 2021 1:33 pm

dprovinciani wrote:I see that some of you got this crash even with CEF 94. Did anyone try with a newer version?

I'm currently using 95.7.14 and I see the crash if I remove my workaround from my project.
DavidK71
Newbie
 
Posts: 2
Joined: Sun Nov 07, 2021 3:25 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 40 guests