Crashing on CefInitialize

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 on CefInitialize

Postby G0apher » Tue Jul 16, 2019 9:56 am

Hi - In my Mac application that has CEF embedded in a view, I get a crash on calling CefInitialize with the below stack. The settings.external_message_pump is true, and the rest of the options are defaults. The initialize call looks like this:
Code: Select all
 
    CefMainArgs main_args(0, 0);   
    CefSettings settings;
    settings.command_line_args_disabled = true;
    settings.external_message_pump = true;
    bool val = CefInitialize(main_args, settings, nullptr, nullptr);

Where should I debug next to find the malloc mismatch? Does CEF have any runtime flags to turn Off custom allocators? Thanks for any pointers.

Code: Select all
#0   0x0000000132a486a0 in base::allocator::StoreZoneFunctions(_ChromeMallocZone const*, base::allocator::MallocZoneFunctions*) [inlined] at /Users/spotify-buildagent/buildAgent/work/4e2ed4f54ddac5f/CEF3_git/chromium/src/out/Debug_GN_x64/../../base/allocator/malloc_zone_functions_mac.cc:26
#1   0x0000000132a4869f in base::allocator::StoreMallocZone(_ChromeMallocZone*) at /Users/spotify-buildagent/buildAgent/work/4e2ed4f54ddac5f/CEF3_git/chromium/src/out/Debug_GN_x64/../../base/allocator/malloc_zone_functions_mac.cc:81
#2   0x0000000132a4782d in base::allocator::StoreFunctionsForAllZones() at /Users/spotify-buildagent/buildAgent/work/4e2ed4f54ddac5f/CEF3_git/chromium/src/out/Debug_GN_x64/../../base/allocator/allocator_interception_mac.mm:324
#3   0x0000000132b3f49d in base::allocator::InitializeAllocatorShim() at /Users/spotify-buildagent/buildAgent/work/4e2ed4f54ddac5f/CEF3_git/chromium/src/out/Debug_GN_x64/../../base/allocator/allocator_shim.cc:315
#4   0x0000000133fdf533 in service_manager::MainInitialize(service_manager::MainParams&) at /Users/spotify-buildagent/buildAgent/work/CEF3_git/chromium/src/out/Debug_GN_x64/../../services/service_manager/embedder/main.cc:344
#5   0x000000013273889b in CefContext::Initialize(CefMainArgs const&, CefStructBase<CefSettingsTraits> const&, scoped_refptr<CefApp>, void*) at /Users/spotify-buildagent/buildAgent/work/CEF3_git/chromium/src/out/Debug_GN_x64/../../cef/libcef/browser/context.cc:391
#6   0x00000001327385e3 in CefInitialize(CefMainArgs const&, CefStructBase<CefSettingsTraits> const&, scoped_refptr<CefApp>, void*) at /Users/spotify-buildagent/buildAgent/work/CEF3_git/chromium/src/out/Debug_GN_x64/../../cef/libcef/browser/context.cc:236
G0apher
Newbie
 
Posts: 7
Joined: Sat Sep 22, 2018 12:16 am

Re: Crashing on CefInitialize

Postby magreenblatt » Tue Jul 16, 2019 12:45 pm

What macOS and CEF version? Does the crash reproduce when running the cefclient app with --external-message-pump? If not, how does your application differ from cefclient?
magreenblatt
Site Admin
 
Posts: 10556
Joined: Fri May 29, 2009 6:57 pm

Re: Crashing on CefInitialize

Postby G0apher » Tue Jul 16, 2019 9:57 pm

MacOS 10.14.5 (Mojave)
CEF Version: 3.3497.1829.g004ef91 (macosx64)
Does not happen with the cefclient, and happens with latest CEF version as well.
Does having a modal session in the application (before calling CefInitialize) change the way CefInitialize allocates memory (for static objects, for e.g.)? Also, the CefInitialize is called from a separate Bundle than the main Application executable (but on the main thread). I cannot think of any other thing the application is doing differently from the cefclient sample.

Update: When I run the Application using libgmalloc (Guard Malloc enabled) in XCode, the said crash does not occur. CefInitialize succeeds.

Appreciate any help to resolve this. Thanks.
G0apher
Newbie
 
Posts: 7
Joined: Sat Sep 22, 2018 12:16 am

Re: Crashing on CefInitialize

Postby weq » Thu Sep 24, 2020 10:49 am

I am experiencing failure to start on MacOS using latest CEF @ StoreMallocZone in CefInitalize. It only happens when i switch my app to "Release mode". When it runs in debug mode, i get no crashes.. everything is fine...

Any tips on what i could be doing wrong?
weq
Newbie
 
Posts: 5
Joined: Mon Aug 10, 2020 8:23 pm

Re: Crashing on CefInitialize

Postby magreenblatt » Thu Sep 24, 2020 11:45 am

weq wrote:I am experiencing failure to start on MacOS using latest CEF @ StoreMallocZone in CefInitalize. It only happens when i switch my app to "Release mode". When it runs in debug mode, i get no crashes.. everything is fine...

Any tips on what i could be doing wrong?

What CEF version? What macOS and Xcode versions? Does the problem reproduce with the CEF sample apps?
magreenblatt
Site Admin
 
Posts: 10556
Joined: Fri May 29, 2009 6:57 pm

Re: Crashing on CefInitialize

Postby weq » Sun Sep 27, 2020 10:38 pm

@magreenblatt i was asking the previous poster and not filing a bug as such (i wanted to perform more debugging before asking u for help). I think this "Release" issue may be related to nortorisation or hardened runtime support that are intricate to deal with on MacOS...

This is the stack:

Code: Select all
Exception Type:        EXC_BREAKPOINT(SIGTRAP)
Exception Codes:       0x0000000000000002, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Trace/BPT trap: 5
Termination Reason:    Namespace SIGNAL, Code 0x5
Terminating Process:   exc handler[15494]

Thread 0 Crashed::tid_307 Dispatch queue: com.apple.main-thread
0   libcef                           0x0000000117cf8d60 base::allocator::StoreMallocZone(_ChromeMallocZone*) + 784 (malloc_zone_functions_mac.cc:82)
1   libcef                           0x0000000117cf7b2d base::allocator::StoreFunctionsForAllZones() + 77 (allocator_interception_mac.mm:322)
2   libcef                           0x0000000117d10d4d base::allocator::InitializeAllocatorShim() + 13 (allocator_shim.cc:367)
3   libcef                           0x000000011aae0384 service_manager::MainInitialize(service_manager::MainParams&) + 212 (main.cc:290)
4   libcef                           0x00000001178d5890 CefContext::Initialize(CefMainArgs const&, CefStructBase<CefSettingsTraits> const&, scoped_refptr<CefApp>, void*) + 1600
5   libcef                           0x00000001178d51ac CefInitialize(CefMainArgs const&, CefStructBase<CefSettingsTraits> const&, scoped_refptr<CefApp>, void*) + 348 (context.cc:330)
6   libcef                           0x000000011387ca02 cef_initialize + 194 (libcef_dll.cc:112)
7   ???                              0x000000011f9a7852 0 + 4825184338
8   ???                              0x000000011f9a5853 0 + 4825176147
9   ???                              0x00000001138657cb 0 + 4622538699
10  ???                              0x0000000113864fdb 0 + 4622536667
11  ???                              0x0000000113859fa4 0 + 4622491556
12  ???                              0x00000001134df0eb 0 + 4618842347
13  ???                              0x0000000113383a3b 0 + 4617419323
14  ???                              0x000000010f9015db 0 + 4556068315
15  ???                              0x000000010f9017a1 0 + 4556068769
16  com.x.xx        0x000000010ec2628e mono_jit_runtime_invoke + 1550
17  com.x.xx        0x000000010ed5b328 mono_runtime_invoke_checked + 136 (object.c:3220)
18  com.x.xx        0x000000010ed62655 mono_runtime_exec_main_checked + 117 (object.c:5284)
19  com.x.xx        0x000000010eb826fc mono_jit_exec + 364 (driver.c:1328)
20  com.x.xx        0x000000010eb857f6 mono_main + 8790 (driver.c:2715)
21  com.x.xx        0x000000010eb3a77c xamarin_main + 1116 (launcher.m:674)
22  com.x.xx        0x000000010eb3b5c4 main + 36 (launcher.m:693)
23  libdyld.dylib                    0x00007fff670d4cc9 start + 1


Im using:
* cef_binary_83.5.0+gbf03589+chromium-83.0.4103.106_macosx64
* Im running CEF via CefGlue (C#) via Xamarin.Mac (c# wrapper over obj-c)

Its not great technology combo to deal with so Im playing pinpoint the failure currently. Switching to "Release" (compiler switch) could potentially switch other libraries logic also... but researching the stack has indicated that it wouldn't be expected to fail that is why my hunch is the OS is killing the app (violation) of a runtime policy etc. Was hoping the OP had some hints!
weq
Newbie
 
Posts: 5
Joined: Mon Aug 10, 2020 8:23 pm

Re: Crashing on CefInitialize

Postby magreenblatt » Sun Sep 27, 2020 11:33 pm

If you think it’s related to notarization, what entitlements are you using? How does it compare to the Chromium entitlements? See viewtopic.php?f=6&t=16481 for background.
magreenblatt
Site Admin
 
Posts: 10556
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot], ndesktop and 22 guests