[cfe-dev] Address Sanitizer and Objective-C garbage collection (GC) incompatible?

Kostya Serebryany kcc at google.com
Thu Dec 13 23:16:13 PST 2012


Hi Sean,

On Fri, Dec 14, 2012 at 2:58 AM, Sean McBride <sean at rogue-research.com>wrote:

> Hi all,
>
> Has anyone tried asan with Obj-C GC?
>

> They seem incompatible. :(  Even with a trivial example that just calls
> NSApplicationLoad() in main().
>

This is very likely.


>
> The OS spews a bunch of these:
>
> a.out(8598,0x7fff7789c960) malloc: reference count underflow for
> 0x400410660, break on auto_refcount_underflow_error to debug.
> 2012-12-13 13:02:34.723 a.out[8598:707] storing a non-GC object
> 0x109733e48 in a GC collection, break on CFCollection_non_gc_storage_error
> to debug.
>
> then asan spews:
>
> ==8598== ERROR: AddressSanitizer: attempting free on address which was not
> malloc()-ed: 0x00010aab4000
>

This happens if an address allocated by some part of ObjC run-time is
passed to the regular C free (or C++ delete).
It *may* be possible to fix this by intercepting the relevant part of ObjC
run-time in asan library.
I suggest to wait until asan transitions from mach_override to "function
interposition" (soon!) and then give it a try.
Since none of us (asan team) is an ObjC expert and ObjC GC is deprecated we
are unlikely to handle the problem ourselves.

--kcc




>
> I can file a bug with details, but thought I'd check here in case I'm not
> the first to try....
>
> Thanks,
>
> --
> ____________________________________________________________
> Sean McBride, B. Eng                 sean at rogue-research.com
> Rogue Research                        www.rogue-research.com
> Mac Software Developer              Montréal, Québec, Canada
>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121214/6df73e6a/attachment.html>


More information about the cfe-dev mailing list