Dear Experts,
When I try to use Address Sanitizer on my iOS app, it reports "attempting free on address which was not malloc()-ed" whenever a C++ exception is caught.
If first saw it inside Apple's libFontParser and filed FB13271831, but I now see it in my own code. The Address Sanitizer stack trace always starts like this:
#1 0x215766ae8 in __cxa_decrement_exception_refcount+0x40 (/usr/lib/libc++abi.dylib:arm64e+0x13ae8)
Having looked up __cxa_decrement_exception_refcount
in the C++ ABI docs, my guess is that the C++ runtime is creating and destroying the exception objects in some way that Address Sanitizer doesn't properly understand, causing it to think that they are being freed without having been allocated by malloc.
This is only really a problem because it does not seem possible to continue after ASan has reported this error; the app is terminated.
Question: is there a way to tell Address Sanitiser to ignore errors in this function? And/or, is there a way to continue after the error?
Thanks.
Hello,
Thank you for the report! There is a known issue with ASan when running on device with iOS 17. It'll mainly show up when using C++. We expect simulator to work fine. I think there's a typo in your suggested workaround. It should be environment variable ASAN_OPTIONS
with value halt_on_error=0
(i.e. 0 means do not halt on error). Unfortunately, if simulator is not appropriate, there's not really any better workarounds at the moment. I'd expect most false positives are coming from free()
'ing an exception like in your backtrace __cxa_decrement_exception_refcount
.