[patch v1] malloc: add malloc_zero_aborts tunable

DJ Delorie dj@redhat.com
Thu Feb 12 20:59:19 GMT 2026


Paul Eggert <eggert@cs.ucla.edu> writes:
> On 2/12/26 11:15, DJ Delorie wrote:
>> +  if (bytes == 0 && mp_.malloc_zero_aborts)
>> +    abort();
>
> This would cause malloc to fail to conform to the C standard, something 
> that is far more likely to cause problems (even as an option) than to 
> cure it. Nobody should use such an option.

Agreed, but it's a tool for people who want to know if that part of the
standard is affecting their code, and thus giving them a list of places
to audit to make sure they're handling it correctly.

> Also, it would slow down malloc.

As I mentioned, I'd work on the tail recursion issue later.  The size
would already be in a register (usually) and comparing it to zero is
cheap enough, I'd add all the likelies etc.  I just had this thought and
wanted to get feedback on it before I forgot it ;-)



More information about the Libc-alpha mailing list