0

I have recently started using the XCode AddressSanitizer, which I think was introduced in XCode 7 (see e.g. Apple WWDC presentation), to help with a difficult to find strange error. The Sanitizer actually found a problem, but I have a hard time interpreting what it means.

Do you know of an overview of the type of errors that AddressSanitizer can report and an explanation of them?

In my specific case, the error is reported deep inside iOS libraries, eventually originating from my code:

[CATransaction commit];

The reported error is:

==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'

Does anybody know what this specific error means?

fishinear
  • 6,101
  • 3
  • 36
  • 84
  • Just glancing at it, it appears you've run out of memory. Is that possible? – matt Apr 13 '16 at 18:19
  • The `commit` is interesting too: that's not a very common thing to do. – matt Apr 13 '16 at 18:19
  • Aha, you mean the AddressSanitizer itself actually causes this error, because it needs to allocate much more memory? That can make sense, but is not the memory problem I was trying to find. – fishinear Apr 13 '16 at 18:23
  • 1
    I would say you've _exposed_ the problem using Address Sanitizer but that Address Sanitizer is a red herring. If you were already having a memory issue, you may have gone down the wrong debugging road; you want to use Instruments. That's just a guess; clearly there is a lot going on here that you have decided to conceal, which is not a very nice way to ask a question and not a very good way to get a helpful answer. – matt Apr 13 '16 at 18:25
  • The `commit` is following a `begin` and `setDisableActions:YES` to disable the implicit animations when manipulating CALayers. – fishinear Apr 13 '16 at 18:25
  • But you don't need the `begin` or `commit` for that; just disable actions and stand back. – matt Apr 13 '16 at 18:26
  • The problem I am trying to locate is probably some type of memory problem, probably overwriting de-allocated memory. See my other question for details: http://stackoverflow.com/questions/36597727/kvo-crash-on-uitextfield-initwithframe?noredirect=1#comment60797961_36597727 – fishinear Apr 13 '16 at 18:28
  • Right, well, I'm sorry about that, but the crash you are seeing in that other question is probably purely diagnostic. The deallocation of the object pointed to probably happened long ago. You need to run under NSZombies and see if you can reproduce the issue. If you can't, you're kind of up a creek. – matt Apr 13 '16 at 18:31
  • I tried with Zombies, but could not reproduce the problem that way, and so tried the new tool that supposedly can do what zombies does, but much more. You helped me interpret the results of that, so many thanks. – fishinear Apr 13 '16 at 18:35
  • Well, I didn't actually help. I'm just guessing. An issue that you can't reproduce is going to be very hard to fix. :( – matt Apr 13 '16 at 18:48

1 Answers1

2

AddressSanitizer uses a custom memory allocator, and it runs out of memory in this particular case. This does not necessarily denote a problem in ASan itself or your program.

Glider
  • 353
  • 3
  • 5