[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.

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.