These leaks are detected by leak sanitizer for darwin.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
test/asan/TestCases/Darwin/malloc_set_zone_name-mprotect.cc | ||
---|---|---|
52 ↗ | (On Diff #94966) | Who's holding (and leaking) the buffer? |
test/asan/TestCases/Darwin/malloc_set_zone_name-mprotect.cc | ||
---|---|---|
52 ↗ | (On Diff #94966) | From looking at the only malloc_set_zone_name source I could find (https://opensource.apple.com/source/Libc/Libc-320.1.3/gen/malloc.c), it looks like libc itself is holding a copy, which it frees whenever the name is overwritten. For some reason, malloc_destroy_zone doesn't free that buffer (I assume it should). |
test/asan/TestCases/Darwin/malloc_set_zone_name-mprotect.cc | ||
---|---|---|
52 ↗ | (On Diff #94966) | Another alternative which would probably work would be calling 'free(malloc_get_zone_name(zone))`, but that seemed hackier. |
test/asan/TestCases/Darwin/malloc_set_zone_name-mprotect.cc | ||
---|---|---|
52 ↗ | (On Diff #94966) | Looking at the code, it's not a leak. The zone name buffer is allocated within the zone itself, so destroying the zone effectively deallocates the name too. |
test/asan/TestCases/Darwin/malloc_set_zone_name-mprotect.cc | ||
---|---|---|
52 ↗ | (On Diff #94966) | This leaks because we have an interceptor for malloc_destroy_zone, which doesn't really destroy the zone, nor does it free the name (see sanitizer_malloc_mac.inc). Could this be fixed in the interceptor instead? |
test/asan/TestCases/Darwin/malloc_set_zone_name-mprotect.cc | ||
---|---|---|
52 ↗ | (On Diff #94966) | Right, what I meant to say, the actual malloc does not leak the name. Fixing it in the interceptor sounds like a better idea. |
test/asan/TestCases/Darwin/malloc_set_zone_name-mprotect.cc | ||
---|---|---|
52 ↗ | (On Diff #94966) | Changing the interceptor to free the name does fix the leak, I'll pull that out into a separate patch. |
test/asan/TestCases/Darwin/malloc_set_zone_name-mprotect.cc | ||
---|---|---|
52 ↗ | (On Diff #94966) | Great, thanks! |