process termination on malloc failure

Do not post support requests, bug reports or feature requests. Discuss CEF here. Non-CEF related discussion goes in General Discussion!

process termination on malloc failure

Postby robs » Fri Oct 17, 2014 10:39 am

Hello,

Chrome has a security feature that causes the process to terminate should malloc fail. This is implemented here for mac:

http://src.chromium.org/svn/trunk/src/b ... ory_mac.mm

and is turned on when EnableTerminationOnOutOfMemory() is called.

There is also an UncheckedMalloc() function for cases where you promise to check the return value for null.

My application needs to be able to attempt a very large memory allocation and handle the case where it could fail. However, due to this security feature of Chrome any attempt at a too-large-malloc will crash instead of returning NULL. Is there any known way to disable this for CEF or to gain access to the UncheckedMalloc() via CEF? Poking around in the code I didn't see any switch to turn this off. I understand for Chrome this is an important feature but in the context of my application security isn't as important.

Thanks for any tips!
robs
Mentor
 
Posts: 70
Joined: Wed Jun 05, 2013 2:22 pm

Re: process termination on malloc failure

Postby magreenblatt » Fri Oct 17, 2014 10:53 am

robs wrote:My application needs to be able to attempt a very large memory allocation and handle the case where it could fail.

You should probably use mmap of equivalent instead. See for example https://developer.apple.com/library/mac ... Alloc.html if you're using OS X.
magreenblatt
Site Admin
 
Posts: 12383
Joined: Fri May 29, 2009 6:57 pm

Re: process termination on malloc failure

Postby robs » Fri Oct 17, 2014 1:56 pm

You should probably use mmap of equivalent instead. See for example https://developer.apple.com/library/mac ... Alloc.html if you're using OS X.


Ah, great! Thanks so much for the tip and the link. That works perfectly.

Rob
robs
Mentor
 
Posts: 70
Joined: Wed Jun 05, 2013 2:22 pm


Return to CEF Discussion

Who is online

Users browsing this forum: No registered users and 22 guests