Page 1 of 2

cefclient crashes (CEF 112.2.0)

PostPosted: Tue Mar 14, 2023 1:58 am
by naoki5
I downloaded binary distribution (cef_binary_112.2.0+gf8b9812+chromium-112.0.5615.9_windows32_beta.tar.bz2) and built it with VS 2022.
I added code to cefclient to specify the cache path.
Code: Select all
// cefclient_win.cc 84
PWSTR pPath = NULL;
::SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_INIT | KF_FLAG_CREATE, NULL, &pPath);
std::wstring strPath(pPath);
::CoTaskMemFree(pPath);
strPath += L"\\myapp\\cache";
CefString(&settings.cache_path) = strPath;


cefclient does not start normally and crashes.
cefclient crashes after displaying the window and before the Google page is displayed.
This issue occurs in debug builds.
release build will boot successfully.

Below is the contents of debug.log.
Code: Select all
[0314/154734.581:WARNING:chrome_browser_cloud_management_controller.cc(87)] Could not create policy manager as CBCM is not enabled.
[0314/154738.286:FATAL:file_util_win.cc(1148)] Unsafe to deny execute access to path : C:\Users\username\AppData\Roaming\myapp\cache\Local Storage\leveldb\LOG


This is call stack when cefclient crashes.
Code: Select all
>   libcef.dll!logging::LogMessage::~LogMessage() 行 968   C++
    libcef.dll!base::PreventExecuteMapping(const base::FilePath & path) 行 1148   C++
    libcef.dll!base::File::DoInitialize(const base::FilePath & path, unsigned int flags) 行 475   C++
    libcef.dll!base::File::Initialize(const base::FilePath & path, unsigned int flags) 行 98   C++
    libcef.dll!base::File::File(const base::FilePath & path, unsigned int flags) 行 34   C++
    libcef.dll!storage::FilesystemImpl::OpenFile(const base::FilePath & path, storage::mojom::FileOpenMode mode, storage::mojom::FileReadAccess read_access, storage::mojom::FileWriteAccess write_access, base::OnceCallback<void (base::File::Error, base::File)> callback) 行 198   C++
    libcef.dll!storage::mojom::DirectoryStubDispatch::AcceptWithResponder(storage::mojom::Directory * impl, mojo::Message * message, std::Cr::unique_ptr<mojo::MessageReceiverWithStatus,std::Cr::default_delete<mojo::MessageReceiverWithStatus>> responder) 行 5204   C++
    libcef.dll!storage::mojom::DirectoryStub<mojo::RawPtrImplRefTraits<storage::mojom::Directory>>::AcceptWithResponder(mojo::Message * message, std::Cr::unique_ptr<mojo::MessageReceiverWithStatus,std::Cr::default_delete<mojo::MessageReceiverWithStatus>> responder) 行 492   C++
    [インライン フレーム] libcef.dll!base::WeakPtr<mojo::InterfaceEndpointClient>::get() 行 256   C++
    [インライン フレーム] libcef.dll!base::WeakPtr<mojo::InterfaceEndpointClient>::operator bool() 行 273   C++
    libcef.dll!mojo::InterfaceEndpointClient::HandleValidatedMessage(mojo::Message * message) 行 1010   C++
    libcef.dll!mojo::InterfaceEndpointClient::HandleIncomingMessageThunk::Accept(mojo::Message * message) 行 357   C++
    libcef.dll!mojo::MessageDispatcher::Accept(mojo::Message * message) 行 43   C++
    libcef.dll!mojo::InterfaceEndpointClient::HandleIncomingMessage(mojo::Message * message) 行 694   C++
    libcef.dll!mojo::internal::MultiplexRouter::ProcessIncomingMessage(mojo::internal::MultiplexRouter::MessageWrapper * message_wrapper, mojo::internal::MultiplexRouter::ClientCallBehavior client_call_behavior, base::SequencedTaskRunner * current_task_runner) 行 1095   C++
    libcef.dll!mojo::internal::MultiplexRouter::Accept(mojo::Message * message) 行 713   C++
    libcef.dll!mojo::MessageDispatcher::Accept(mojo::Message * message) 行 43   C++
    libcef.dll!mojo::Connector::DispatchMessageW(mojo::ScopedHandleBase<mojo::MessageHandle> handle) 行 549   C++
    libcef.dll!mojo::Connector::ReadAllAvailableMessages() 行 607   C++
    libcef.dll!mojo::Connector::OnHandleReadyInternal(unsigned int result) 行 440   C++
    [インライン フレーム] libcef.dll!base::internal::FunctorTraits<void (net::(anonymous namespace)::DnsTCPAttempt::*)(int) __attribute__((thiscall)),void>::Invoke(void(net::`anonymous namespace'::DnsTCPAttempt::*)(int) method, net::`anonymous namespace'::DnsTCPAttempt * && receiver_ptr, int && args) 行 764   C++
    [インライン フレーム] libcef.dll!base::internal::InvokeHelper<0,void,0>::MakeItSo(void(net::`anonymous namespace'::DnsTCPAttempt::*)(int) && functor, std::Cr::tuple<base::internal::UnretainedWrapper<net::(anonymous namespace)::DnsTCPAttempt,base::unretained_traits::MayNotDangle,0>> && bound, int && args) 行 943   C++
    [インライン フレーム] libcef.dll!base::internal::Invoker<base::internal::BindState<void (net::(anonymous namespace)::DnsTCPAttempt::*)(int) __attribute__((thiscall)),base::internal::UnretainedWrapper<net::(anonymous namespace)::DnsTCPAttempt,base::unretained_traits::MayNotDangle,0>>,void (int)>::RunImpl(void(net::`anonymous namespace'::DnsTCPAttempt::*)(int) && functor, std::Cr::tuple<base::internal::UnretainedWrapper<net::(anonymous namespace)::DnsTCPAttempt,base::unretained_traits::MayNotDangle,0>> && bound, std::Cr::integer_sequence<unsigned int,0> seq, int && unbound_args) 行 1038   C++
    libcef.dll!base::internal::Invoker<base::internal::BindState<void (net::(anonymous namespace)::DnsTCPAttempt::*)(int) __attribute__((thiscall)),base::internal::UnretainedWrapper<net::(anonymous namespace)::DnsTCPAttempt,base::unretained_traits::MayNotDangle,0>>,void (int)>::RunOnce(base::internal::BindStateBase * base, int unbound_args) 行 993   C++
    libcef.dll!base::RepeatingCallback<void (audio::LoopbackGroupMember *)>::Run(audio::LoopbackGroupMember * args) 行 333   C++
    libcef.dll!mojo::SimpleWatcher::DiscardReadyState(const base::RepeatingCallback<void (unsigned int)> & callback, unsigned int result, const mojo::HandleSignalsState & state) 行 193   C++
    [インライン フレーム] libcef.dll!base::internal::FunctorTraits<void (*)(const base::RepeatingCallback<void (unsigned int)> &, unsigned int, const mojo::HandleSignalsState &),void>::Invoke(void(*)(const base::RepeatingCallback<void (unsigned int)> &, unsigned int, const mojo::HandleSignalsState &) & function, const base::RepeatingCallback<void (unsigned int)> & args, unsigned int && args, const mojo::HandleSignalsState & args) 行 654   C++
    [インライン フレーム] libcef.dll!base::internal::InvokeHelper<0,void,0>::MakeItSo(void(*)(const base::RepeatingCallback<void (unsigned int)> &, unsigned int, const mojo::HandleSignalsState &) & functor, const std::Cr::tuple<base::RepeatingCallback<void (unsigned int)>> & bound, unsigned int && args, const mojo::HandleSignalsState & args) 行 943   C++
    [インライン フレーム] libcef.dll!base::internal::Invoker<base::internal::BindState<void (*)(const base::RepeatingCallback<void (unsigned int)> &, unsigned int, const mojo::HandleSignalsState &),base::RepeatingCallback<void (unsigned int)>>,void (unsigned int, const mojo::HandleSignalsState &)>::RunImpl(void(*)(const base::RepeatingCallback<void (unsigned int)> &, unsigned int, const mojo::HandleSignalsState &) & functor, const std::Cr::tuple<base::RepeatingCallback<void (unsigned int)>> & bound, std::Cr::integer_sequence<unsigned int,0> seq, unsigned int && unbound_args, const mojo::HandleSignalsState & unbound_args) 行 1038   C++
    libcef.dll!base::internal::Invoker<base::internal::BindState<void (*)(const base::RepeatingCallback<void (unsigned int)> &, unsigned int, const mojo::HandleSignalsState &),base::RepeatingCallback<void (unsigned int)>>,void (unsigned int, const mojo::HandleSignalsState &)>::Run(base::internal::BindStateBase * base, unsigned int unbound_args, const mojo::HandleSignalsState & unbound_args) 行 1002   C++
    libcef.dll!base::RepeatingCallback<void (const net::CanonicalCookie &, bool *)>::Run(const net::CanonicalCookie & args, bool * args) 行 333   C++
    libcef.dll!mojo::SimpleWatcher::OnHandleReady(int watch_id, unsigned int result, const mojo::HandleSignalsState & state) 行 278   C++
    [インライン フレーム] libcef.dll!base::internal::FunctorTraits<void (mojo::SimpleWatcher::*)(int, unsigned int, const mojo::HandleSignalsState &) __attribute__((thiscall)),void>::Invoke(void(mojo::SimpleWatcher::*)(int, unsigned int, const mojo::HandleSignalsState &) method, base::WeakPtr<mojo::SimpleWatcher> && receiver_ptr, int && args, unsigned int && args, mojo::HandleSignalsState && args) 行 764   C++
    [インライン フレーム] libcef.dll!base::internal::InvokeHelper<1,void,0,1,2,3>::MakeItSo(void(mojo::SimpleWatcher::*)(int, unsigned int, const mojo::HandleSignalsState &) && functor, std::Cr::tuple<base::WeakPtr<mojo::SimpleWatcher>,int,unsigned int,mojo::HandleSignalsState> && bound) 行 966   C++
    [インライン フレーム] libcef.dll!base::internal::Invoker<base::internal::BindState<void (mojo::SimpleWatcher::*)(int, unsigned int, const mojo::HandleSignalsState &) __attribute__((thiscall)),base::WeakPtr<mojo::SimpleWatcher>,int,unsigned int,mojo::HandleSignalsState>,void ()>::RunImpl(void(mojo::SimpleWatcher::*)(int, unsigned int, const mojo::HandleSignalsState &) && functor, std::Cr::tuple<base::WeakPtr<mojo::SimpleWatcher>,int,unsigned int,mojo::HandleSignalsState> && bound, std::Cr::integer_sequence<unsigned int,0,1,2,3> seq) 行 1038   C++
    libcef.dll!base::internal::Invoker<base::internal::BindState<void (mojo::SimpleWatcher::*)(int, unsigned int, const mojo::HandleSignalsState &) __attribute__((thiscall)),base::WeakPtr<mojo::SimpleWatcher>,int,unsigned int,mojo::HandleSignalsState>,void ()>::RunOnce(base::internal::BindStateBase * base) 行 993   C++
    [インライン フレーム] libcef.dll!base::OnceCallback<void ()>::Run() 行 152   C++
    libcef.dll!base::TaskAnnotator::RunTaskImpl(base::PendingTask & pending_task) 行 162   C++
    [インライン フレーム] libcef.dll!base::TaskAnnotator::RunTask(perfetto::StaticString event_name, base::PendingTask & pending_task, base::internal::TaskTracker::RunTaskImpl::<lambda_0> && args) 行 88   C++
    [インライン フレーム] libcef.dll!base::internal::TaskTracker::RunTaskImpl(base::internal::Task & task, const base::TaskTraits & traits, base::internal::TaskSource * task_source, const base::SequenceToken & token) 行 649   C++
    libcef.dll!base::internal::TaskTracker::RunSkipOnShutdown(base::internal::Task & task, const base::TaskTraits & traits, base::internal::TaskSource * task_source, const base::SequenceToken & token) 行 634   C++
    [インライン フレーム] libcef.dll!base::internal::TaskTracker::RunTaskWithShutdownBehavior(base::internal::Task & task, const base::TaskTraits & traits, base::internal::TaskSource * task_source, const base::SequenceToken & token) 行 664   C++
    libcef.dll!base::internal::TaskTracker::RunTask(base::internal::Task task, base::internal::TaskSource * task_source, const base::TaskTraits & traits) 行 495   C++
    libcef.dll!base::internal::TaskTracker::RunAndPopNextTask(base::internal::RegisteredTaskSource task_source) 行 406   C++
    libcef.dll!base::internal::WorkerThread::RunWorker() 行 480   C++
    libcef.dll!base::internal::WorkerThread::RunPooledWorker() 行 357   C++
    libcef.dll!base::`anonymous namespace'::ThreadFunc(void * params) 行 126   C++
    [外部コード]   
    [下のフレームは間違っているか、または見つかりません。kernel32.dll に対して読み込まれたシンボルはありません]   


When I link the CEF created by this distribution with my application, it prints the same message to debug.log and does not start.

Windows 11 Pro (22H2) Japanese
Visual Studio 2022 Version 17.5.1
Windows SDK Version 10.0.22621.0

Re: cefclient crashes (CEF 112.2.0)

PostPosted: Tue Mar 14, 2023 9:09 am
by magreenblatt
See the related Chromium code for an explanation: https://source.chromium.org/chromium/ch ... 885299dabb

Re: cefclient crashes (CEF 112.2.0)

PostPosted: Wed Mar 15, 2023 12:22 am
by naoki5
thank you for your reply.
I saw that code.
Could it be that the cache path is not correct?
Or is there a way to set the path as "safe"?
Any hint will help me.

Re: cefclient crashes (CEF 112.2.0)

PostPosted: Wed Mar 15, 2023 1:16 am
by amaitland
Try using Local App Data instead of Roaming.

Re: cefclient crashes (CEF 112.2.0)

PostPosted: Wed Mar 15, 2023 1:39 am
by naoki5
amaitland wrote:Try using Local App Data instead of Roaming.


Thanks.
I tried Local App Data and the result was the same.
Code: Select all
[0315/152300.057:WARNING:chrome_browser_cloud_management_controller.cc(87)] Could not create policy manager as CBCM is not enabled.
[0315/152300.303:FATAL:file_util_win.cc(1148)] Unsafe to deny execute access to path : C:\Users\username\AppData\Local\myapp\cache\Local Storage\leveldb\LOG


I have been using App Data Roaming for some time in my application and have had no problems.
This problem has been present since CEF 112.

Re: cefclient crashes (CEF 112.2.0)

PostPosted: Wed Mar 15, 2023 3:14 am
by amaitland
Testing with https://cef-builds.spotifycdn.com/cef_b ... nt.tar.bz2

Code: Select all
cefclient --cache-path=C:\Users\alex\AppData\Local\CEF\cache\local


I'm not seeing any errors. Loading chrome://version/ works as expected

Code: Select all
cefclient --cache-path=C:\Users\alex\AppData\Roaming\CEF\Cache


Also works.

Re: cefclient crashes (CEF 112.2.0)

PostPosted: Wed Mar 15, 2023 4:31 am
by naoki5
amaitland wrote:Testing with https://cef-builds.spotifycdn.com/cef_b ... nt.tar.bz2

Code: Select all
cefclient --cache-path=C:\Users\alex\AppData\Local\CEF\cache\local


I'm not seeing any errors. Loading chrome://version/ works as expected

Code: Select all
cefclient --cache-path=C:\Users\alex\AppData\Roaming\CEF\Cache


Also works.


Release build works.
The above phenomenon occurs in debug build.

I'm using Windows 32-bit version, but I've also tried 64-bit version.
Similarly, debug builds are not launched.

Re: cefclient crashes (CEF 112.2.0)

PostPosted: Mon Mar 20, 2023 12:03 am
by naoki5
Same result with CEF 112.2.6.
Debug build cannot launch successfully.
Release build works.

Code: Select all
cefclient.exe --cache-path=c:\users\username\appdata\local\cef\cache

Re: cefclient crashes (CEF 112.2.0)

PostPosted: Mon May 08, 2023 1:30 am
by naoki5
I found the cause.

I tried running "IsPathSafeToSetAclOn" with the debugger.
GetTempPath API was called internally to get the temporary directory.
GetTempPath returned "C:\Users\user\AppData\Local\Temp".
It seems to fail if it is not in this directory.

I was guessing from the source code comments that both Roaming AppData and Local AppData should be fine.
I would change the cache_path to inside the AppData\Local\Temp.

Re: cefclient crashes (CEF 112.2.0)

PostPosted: Sun May 14, 2023 1:57 pm
by danielw
Thanks for posting the solution.
I googled for a very long time but found no results, I had to search specifically on this forum to find a fix.