我最近开始使用XCode AddressSanitizer,我认为它是在XCode 7中引入的(参见例如Apple WWDC presentation),以帮助找到一个难以发现的奇怪错误。 Sanitizer实际上发现了一个问题,但我很难解释它的含义。
您是否知道AddressSanitizer可以报告的错误类型概述及其解释?
在我的特定情况下,错误会在iOS库中深深报告,最终源自我的代码:
[CATransaction commit];
报告的错误是:
==820==ERROR: AddressSanitizer failed to allocate 0x4b8000 (4947968) bytes of LargeMmapAllocator (error code: 12)
==820==Process memory map follows:
0x0193820000-0x019383d000 /System/Library/CoreServices/Encodings/libJapaneseConverter.dylib
0x019fb17000-0x019fb17020 /System/Library/CoreServices/Encodings/libJapaneseConverter.dylib
... very long list of mapped memory ...
==820==End of process memory map.
==820==AddressSanitizer CHECK failed: /Library/Caches/com.apple.xbs/Sources/clang/clang-703.0.29/src/projects/compiler-rt/lib/sanitizer_common/sanitizer_common.cc:181 "((0 && "unable to mmap")) != (0)" (0x0, 0x0)
ERROR: Failed to mmap
AddressSanitizer report breakpoint hit. Use 'thread info -s' to get extended information about the report.
(lldb) thread info -s
thread #1: tid = 0x993ca, 0x0000000100994010 libclang_rt.asan_ios_dynamic.dylib`__asan::AsanDie(), queue = 'com.apple.main-thread'
有人知道这个特定错误意味着什么吗?
答案 0 :(得分:1)
AddressSanitizer使用自定义内存分配器,在这种特殊情况下它会耗尽内存。这并不一定表示ASan本身或您的程序存在问题。