Open
Description
I am running on Mac M1
with clang version 13.0.1
.
When I run the leak sanitizer for example code shown in the Clang 13 documentation,
$ cat memory-leak.c
#include <stdlib.h>
void *p;
int main() {
p = malloc(7);
p = 0; // The memory is leaked here.
return 0;
}
$ clang -fsanitize=address -g memory-leak.c ; ASAN_OPTIONS=detect_leaks=1 ./a.out
the output shows that "4071 byte(s) leaked in 128 allocation(s)", with many of the leaked bytes coming from objects in the <unknown module>
.
I also tested it against the code shown below:
$ cat memory-leak.c
int main()
{
return 0;
}
$ clang -fsanitize=address -g memory-leak.c ; ASAN_OPTIONS=detect_leaks=1 ./a.out
It shows that "4064 byte(s) leaked in 127 allocation(s)".
It appears that by default, there are 4064 bytes leaked. The complete output of the second program is shown below.
==72058==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 1856 byte(s) in 58 object(s) allocated from:
#0 0x1030c7a2c in wrap_calloc+0x94 (libclang_rt.asan_osx_dynamic.dylib:arm64+0x3fa2c)
#1 0x19a4be484 in realizeClassWithoutSwift(objc_class*, objc_class*)+0x8c (libobjc.A.dylib:arm64+0x5484)
#2 0x315b00019a4be608 (<unknown module>)
#3 0x7c1280019a4bc61c (<unknown module>)
#4 0x7a3000019a4baf40 (<unknown module>)
#5 0xf74c000102ce7948 (<unknown module>)
#6 0x311e800102ce2988 (<unknown module>)
#7 0x749800102ce780c (<unknown module>)
#8 0xb511000102cfc800 (<unknown module>)
#9 0x3c5580019a4bae04 (<unknown module>)
#10 0x301b00019a4754e0 (<unknown module>)
#11 0xe4880019a484cbc (<unknown module>)
#12 0x6e148001a51806a4 (<unknown module>)
#13 0xa842800102cedd8c (<unknown module>)
#14 0x732800102d1717c (<unknown module>)
#15 0x194c800102d0dbc8 (<unknown module>)
#16 0x9221800102cd9f94 (<unknown module>)
#17 0x2d1d000102d0d970 (<unknown module>)
#18 0x307a000102d16bcc (<unknown module>)
#19 0x957f800102cedccc (<unknown module>)
#20 0x5f22000102cf47c8 (<unknown module>)
#21 0x1325800102d02fe8 (<unknown module>)
#22 0x431b800102cdddb4 (<unknown module>)
#23 0xfc30000102cdd064 (<unknown module>)
#24 0x4737ffffffffffc (<unknown module>)
Direct leak of 1856 byte(s) in 58 object(s) allocated from:
#0 0x1030c7a2c in wrap_calloc+0x94 (libclang_rt.asan_osx_dynamic.dylib:arm64+0x3fa2c)
#1 0x19a4be484 in realizeClassWithoutSwift(objc_class*, objc_class*)+0x8c (libobjc.A.dylib:arm64+0x5484)
#2 0x7c1280019a4bc61c (<unknown module>)
#3 0x7a3000019a4baf40 (<unknown module>)
#4 0xf74c000102ce7948 (<unknown module>)
#5 0x311e800102ce2988 (<unknown module>)
#6 0x749800102ce780c (<unknown module>)
#7 0xb511000102cfc800 (<unknown module>)
#8 0x3c5580019a4bae04 (<unknown module>)
#9 0x301b00019a4754e0 (<unknown module>)
#10 0xe4880019a484cbc (<unknown module>)
#11 0x6e148001a51806a4 (<unknown module>)
#12 0xa842800102cedd8c (<unknown module>)
#13 0x732800102d1717c (<unknown module>)
#14 0x194c800102d0dbc8 (<unknown module>)
#15 0x9221800102cd9f94 (<unknown module>)
#16 0x2d1d000102d0d970 (<unknown module>)
#17 0x307a000102d16bcc (<unknown module>)
#18 0x957f800102cedccc (<unknown module>)
#19 0x5f22000102cf47c8 (<unknown module>)
#20 0x1325800102d02fe8 (<unknown module>)
#21 0x431b800102cdddb4 (<unknown module>)
#22 0xfc30000102cdd064 (<unknown module>)
#23 0x4737ffffffffffc (<unknown module>)
Direct leak of 160 byte(s) in 5 object(s) allocated from:
#0 0x1030c7a2c in wrap_calloc+0x94 (libclang_rt.asan_osx_dynamic.dylib:arm64+0x3fa2c)
#1 0x19a4be484 in realizeClassWithoutSwift(objc_class*, objc_class*)+0x8c (libobjc.A.dylib:arm64+0x5484)
#2 0xa15f80019a4be5f0 (<unknown module>)
#3 0x7c1280019a4bc61c (<unknown module>)
#4 0x7a3000019a4baf40 (<unknown module>)
#5 0xf74c000102ce7948 (<unknown module>)
#6 0x311e800102ce2988 (<unknown module>)
#7 0x749800102ce780c (<unknown module>)
#8 0xb511000102cfc800 (<unknown module>)
#9 0x3c5580019a4bae04 (<unknown module>)
#10 0x301b00019a4754e0 (<unknown module>)
#11 0xe4880019a484cbc (<unknown module>)
#12 0x6e148001a51806a4 (<unknown module>)
#13 0xa842800102cedd8c (<unknown module>)
#14 0x732800102d1717c (<unknown module>)
#15 0x194c800102d0dbc8 (<unknown module>)
#16 0x9221800102cd9f94 (<unknown module>)
#17 0x2d1d000102d0d970 (<unknown module>)
#18 0x307a000102d16bcc (<unknown module>)
#19 0x957f800102cedccc (<unknown module>)
#20 0x5f22000102cf47c8 (<unknown module>)
#21 0x1325800102d02fe8 (<unknown module>)
#22 0x431b800102cdddb4 (<unknown module>)
#23 0xfc30000102cdd064 (<unknown module>)
#24 0x4737ffffffffffc (<unknown module>)
Direct leak of 128 byte(s) in 4 object(s) allocated from:
#0 0x1030c7a2c in wrap_calloc+0x94 (libclang_rt.asan_osx_dynamic.dylib:arm64+0x3fa2c)
#1 0x19a4be484 in realizeClassWithoutSwift(objc_class*, objc_class*)+0x8c (libobjc.A.dylib:arm64+0x5484)
#2 0x566380019a4be608 (<unknown module>)
#3 0xa15f80019a4be5f0 (<unknown module>)
#4 0x7c1280019a4bc61c (<unknown module>)
#5 0x7a3000019a4baf40 (<unknown module>)
#6 0xf74c000102ce7948 (<unknown module>)
#7 0x311e800102ce2988 (<unknown module>)
#8 0x749800102ce780c (<unknown module>)
#9 0xb511000102cfc800 (<unknown module>)
#10 0x3c5580019a4bae04 (<unknown module>)
#11 0x301b00019a4754e0 (<unknown module>)
#12 0xe4880019a484cbc (<unknown module>)
#13 0x6e148001a51806a4 (<unknown module>)
#14 0xa842800102cedd8c (<unknown module>)
#15 0x732800102d1717c (<unknown module>)
#16 0x194c800102d0dbc8 (<unknown module>)
#17 0x9221800102cd9f94 (<unknown module>)
#18 0x2d1d000102d0d970 (<unknown module>)
#19 0x307a000102d16bcc (<unknown module>)
#20 0x957f800102cedccc (<unknown module>)
#21 0x5f22000102cf47c8 (<unknown module>)
#22 0x1325800102d02fe8 (<unknown module>)
#23 0x431b800102cdddb4 (<unknown module>)
#24 0xfc30000102cdd064 (<unknown module>)
#25 0x4737ffffffffffc (<unknown module>)
Direct leak of 32 byte(s) in 1 object(s) allocated from:
#0 0x1030c7a2c in wrap_calloc+0x94 (libclang_rt.asan_osx_dynamic.dylib:arm64+0x3fa2c)
#1 0x19a4be484 in realizeClassWithoutSwift(objc_class*, objc_class*)+0x8c (libobjc.A.dylib:arm64+0x5484)
#2 0xaa7f80019a4be5f0 (<unknown module>)
#3 0xa15f80019a4be5f0 (<unknown module>)
#4 0x7c1280019a4bc61c (<unknown module>)
#5 0x7a3000019a4baf40 (<unknown module>)
#6 0xf74c000102ce7948 (<unknown module>)
#7 0x311e800102ce2988 (<unknown module>)
#8 0x749800102ce780c (<unknown module>)
#9 0xb511000102cfc800 (<unknown module>)
#10 0x3c5580019a4bae04 (<unknown module>)
#11 0x301b00019a4754e0 (<unknown module>)
#12 0xe4880019a484cbc (<unknown module>)
#13 0x6e148001a51806a4 (<unknown module>)
#14 0xa842800102cedd8c (<unknown module>)
#15 0x732800102d1717c (<unknown module>)
#16 0x194c800102d0dbc8 (<unknown module>)
#17 0x9221800102cd9f94 (<unknown module>)
#18 0x2d1d000102d0d970 (<unknown module>)
#19 0x307a000102d16bcc (<unknown module>)
#20 0x957f800102cedccc (<unknown module>)
#21 0x5f22000102cf47c8 (<unknown module>)
#22 0x1325800102d02fe8 (<unknown module>)
#23 0x431b800102cdddb4 (<unknown module>)
#24 0xfc30000102cdd064 (<unknown module>)
#25 0x4737ffffffffffc (<unknown module>)
Direct leak of 32 byte(s) in 1 object(s) allocated from:
#0 0x1030c7a2c in wrap_calloc+0x94 (libclang_rt.asan_osx_dynamic.dylib:arm64+0x3fa2c)
#1 0x19a4be484 in realizeClassWithoutSwift(objc_class*, objc_class*)+0x8c (libobjc.A.dylib:arm64+0x5484)
#2 0xfa5b00019a4be608 (<unknown module>)
#3 0xaa7f80019a4be5f0 (<unknown module>)
#4 0xa15f80019a4be5f0 (<unknown module>)
#5 0x7c1280019a4bc61c (<unknown module>)
#6 0x7a3000019a4baf40 (<unknown module>)
#7 0xf74c000102ce7948 (<unknown module>)
#8 0x311e800102ce2988 (<unknown module>)
#9 0x749800102ce780c (<unknown module>)
#10 0xb511000102cfc800 (<unknown module>)
#11 0x3c5580019a4bae04 (<unknown module>)
#12 0x301b00019a4754e0 (<unknown module>)
#13 0xe4880019a484cbc (<unknown module>)
#14 0x6e148001a51806a4 (<unknown module>)
#15 0xa842800102cedd8c (<unknown module>)
#16 0x732800102d1717c (<unknown module>)
#17 0x194c800102d0dbc8 (<unknown module>)
#18 0x9221800102cd9f94 (<unknown module>)
#19 0x2d1d000102d0d970 (<unknown module>)
#20 0x307a000102d16bcc (<unknown module>)
#21 0x957f800102cedccc (<unknown module>)
#22 0x5f22000102cf47c8 (<unknown module>)
#23 0x1325800102d02fe8 (<unknown module>)
#24 0x431b800102cdddb4 (<unknown module>)
#25 0xfc30000102cdd064 (<unknown module>)
#26 0x4737ffffffffffc (<unknown module>)
SUMMARY: AddressSanitizer: 4064 byte(s) leaked in 127 allocation(s).