Anna Zaks
2015-Mar-10 23:40 UTC
[LLVMdev] [asan] The default value of 'allocator_may_return_null'
Hi, There seems to be a discrepancy between what the default value of 'allocator_may_return_null' should be: source code: ./lib/sanitizer_common/sanitizer_flags.inc:COMMON_FLAG(bool, allocator_may_return_null, false, docs (https://code.google.com/p/address-sanitizer/wiki/Flags): allocator_may_return_null 1 If false, the allocator will crash instead of returning 0 on out-of-memory. I suspect that the reason to have it default to 'false' is because that would provide for a more predictable out of memory behavior in most use cases. Is that the case or should this be system dependent and match the default system allocator? Thanks, Anna. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150310/dbfa8441/attachment.html>
Kostya Serebryany
2015-Mar-10 23:54 UTC
[LLVMdev] [asan] The default value of 'allocator_may_return_null'
On Tue, Mar 10, 2015 at 4:40 PM, Anna Zaks <ganna at apple.com> wrote:> Hi, > > There seems to be a discrepancy between what the default value of > 'allocator_may_return_null' should be: > source code: > ./lib/sanitizer_common/sanitizer_flags.inc:COMMON_FLAG(bool, > allocator_may_return_null, false, > > docs (https://code.google.com/p/address-sanitizer/wiki/Flags): > allocator_may_return_null 1 If false, the allocator will crash instead of > returning 0 on out-of-memory. > >Good catch, fixed the wiki.> I suspect that the reason to have it default to 'false' is because that > would provide for a more predictable out of memory behavior in most use > cases. >Correct.> Is that the case or should this be system dependent and match the default > system allocator? >Errr.. I don't think so. asan's allocator is very different from "a system allocator" in many other ways. E.g. it consumes more memory, and so a program that runs normally w/ a system allocator will OOM with asan. It's better to have asan crash instantly on OOM rather than returning 0. The user is then notified about the flag.> > Thanks, > Anna. >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150310/ee71064b/attachment.html>