Skip to content

Possible to set MallocNanoZone=0 in the environment on macOS #1666

Open
@chandlerc

Description

@chandlerc

As documented in various places such as here:
https://stackoverflow.com/questions/64126942/malloc-nano-zone-abandoned-due-to-inability-to-preallocate-reserved-vm-space

On macOS, ASan allocates memory before malloc which causes the macOS malloc to complain about being unable to get its "nano zone". As a result, every ASan built binary on macOS prints a line on startup like:

a.out(76093,0x204979e00) malloc: nano zone abandoned due to inability to reserve vm space.

There is an environment variable that disables the nano zone, and avoids spamming this message. But it needs to be set before the malloc code runs. Is it possible to add code to ASan (and other sanitizers) that runs at the same time as the allocations that trigger this to also inject the MallocNanoZone=0 into the environment?

I'd be happy to work on a patch, but I can't make heads or tails of where it would best fit into the overall initialization code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions