Page 1 of 1

PolicyBase::Release Crash on initialize

PostPosted: Fri Oct 22, 2021 6:15 am
by JMilly
When I try to build Cef locally and run cefclient I run into a Check condition issue where ref_count of the PolicyBase class goes below 0 when a scoped_refptr goes out of scope. (It is supposed to be 0 or higher CHECK(result >= 0);)

The strange thing is when I debug it in debug mode I see two values for ref_count depending on how I access the value. In the Scope of PolicyBase::Release

ref_count -1 volatile long
(*((cefclient.exe!sandbox::PolicyBase*)this)).ref_count 1 volatile long


the cast to policybase in the debugger causes ref_count to have a different value then when directly accessing under "this" (which is of type PolicyBase so the cast shouldn't matter)

Even when you remove this check condition there are all sorts of destructor and container issues that trigger conditions. It's like the binary is just garbage doing things that don't make sense.


CallStack:
libcef.dll!sandbox::PolicyBase::Release() Line 132
at I:\c95-2\cef_root\chromium_git\chromium\src\sandbox\win\src\sandbox_policy_base.cc(132)
[Inline Frame] libcef.dll!scoped_refptr<sandbox::TargetPolicy>::Release(sandbox::TargetPolicy * ptr) Line 322
at I:\c95-2\cef_root\chromium_git\chromium\src\base\memory\scoped_refptr.h(322)
[Inline Frame] libcef.dll!scoped_refptr<sandbox::TargetPolicy>::~scoped_refptr() Line 224
at I:\c95-2\cef_root\chromium_git\chromium\src\base\memory\scoped_refptr.h(224)
libcef.dll!sandbox::policy::Sandbox::Initialize(sandbox::policy::SandboxType sandbox_type, sandbox::SandboxInterfaceInfo * sandbox_info) Line 61
at I:\c95-2\cef_root\chromium_git\chromium\src\sandbox\policy\sandbox.cc(61)
libcef.dll!content::ContentMainRunnerImpl::Initialize(const content::ContentMainParams & params) Line 888
at I:\c95-2\cef_root\chromium_git\chromium\src\content\app\content_main_runner_impl.cc(888)
libcef.dll!content::ContentMainInitialize(content::ContentMainParams & params, content::ContentMainRunner * content_main_runner) Line 317
at I:\c95-2\cef_root\chromium_git\chromium\src\content\app\content_main.cc(317)
libcef.dll!CefMainRunner::ContentMainInitialize(const CefMainArgs & args, void * windows_sandbox_info, int * no_sandbox) Line 385
at I:\c95-2\cef_root\chromium_git\chromium\src\cef\libcef\browser\main_runner.cc(385)
libcef.dll!CefMainRunner::Initialize(CefStructBase<CefSettingsTraits> * settings, scoped_refptr<CefApp> application, const CefMainArgs & args, void * windows_sandbox_info, bool * initialized, base::OnceCallback<void ()> context_initialized) Line 235
at I:\c95-2\cef_root\chromium_git\chromium\src\cef\libcef\browser\main_runner.cc(235)
libcef.dll!CefContext::Initialize(const CefMainArgs & args, const CefStructBase<CefSettingsTraits> & settings, scoped_refptr<CefApp> application, void * windows_sandbox_info) Line 359
at I:\c95-2\cef_root\chromium_git\chromium\src\cef\libcef\browser\context.cc(359)
libcef.dll!CefInitialize(const CefMainArgs & args, const CefStructBase<CefSettingsTraits> & settings, scoped_refptr<CefApp> application, void * windows_sandbox_info) Line 215
at I:\c95-2\cef_root\chromium_git\chromium\src\cef\libcef\browser\context.cc(215)
libcef.dll!cef_initialize(const _cef_main_args_t * args, const _cef_settings_t * settings, _cef_app_t * application, void * windows_sandbox_info) Line 112
at I:\c95-2\cef_root\chromium_git\chromium\src\cef\libcef_dll\libcef_dll.cc(112)
cefclient.exe!CefInitialize(const CefMainArgs & args, const CefStructBase<CefSettingsTraits> & settings, scoped_refptr<CefApp> application, void * windows_sandbox_info) Line 106
at I:\c95-2\cef_root\chromium_git\chromium\src\cef\binary_distrib\cef_binary_95.7.10+g00d4ad5+chromium-95.0.4638.54_windows32\libcef_dll\wrapper\libcef_dll_wrapper.cc(106)
cefclient.exe!client::MainContextImpl::Initialize(const CefMainArgs & args, const CefStructBase<CefSettingsTraits> & settings, scoped_refptr<CefApp> application, void * windows_sandbox_info) Line 238
at I:\c95-2\cef_root\chromium_git\chromium\src\cef\binary_distrib\cef_binary_95.7.10+g00d4ad5+chromium-95.0.4638.54_windows32\tests\cefclient\browser\main_context_impl.cc(238)
cefclient.exe!client::`anonymous namespace'::RunMain(HINSTANCE__ * hInstance, int nCmdShow) Line 100
at I:\c95-2\cef_root\chromium_git\chromium\src\cef\binary_distrib\cef_binary_95.7.10+g00d4ad5+chromium-95.0.4638.54_windows32\tests\cefclient\cefclient_win.cc(100)
cefclient.exe!wWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, wchar_t * lpCmdLine, int nCmdShow) Line 137
at I:\c95-2\cef_root\chromium_git\chromium\src\cef\binary_distrib\cef_binary_95.7.10+g00d4ad5+chromium-95.0.4638.54_windows32\tests\cefclient\cefclient_win.cc(137)
[External Code]

Is there something wrong with how I'm building Cef?
--branch=4638 --checkout=00d4ad5
GN_DEFINES = is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome'
GN_ARGS = --sln=cef --ide=vs2019 --filters=//cef/*'

Re: PolicyBase::Release Crash on initialize

PostPosted: Fri Oct 22, 2021 8:28 am
by magreenblatt
You need to add use_thin_lto=false to your GN_DEFINES. See https://bitbucket.org/chromiumembedded/ ... figuration

Re: PolicyBase::Release Crash on initialize

PostPosted: Fri Oct 22, 2021 8:45 am
by JMilly
Thank you I will try a build with that option. I failed to see that change in the build documentation.