Why do sanitizers abort on error by default on mac and android?

Hi,

What is the history of aborting on error on mac and android in a sanitizer? What advantage does it bring versus just exiting non-zero? Why just on these platforms and not all platforms?

(for my own education)

More background:
It seems like the sanitizers die with SIGABT instead of exiting non-zero, but this is platform specific (and may be overridden by the user). From sanitizer_flags.inc:

Why is the behavior different on android and apple? Did this bring some sort of advantage?

It seems like the feature originally existed in ASAN, and was introduced here:

But the commit doesn’t describe why this decision was made.

Pinging @kubamracek , as it looks like you introduced this change way back in 2015. Thanks for any knowledge you can share :slight_smile:

A crash of a process (e.g. through abort() or by segfault-ing) on macOS generates an incredibly useful crashlog file with thread backtraces, and lots more details. Ending the process with exit() doesn’t do that.

2 Likes

Aha!

Thank you for the response, perhaps that is one of the things that contributes to my question from yesterday:

I’ll have to poke around and see if this new info about abort improves anything.

Android is similar to iOS, in that if we call abort() then debuggerd will create a tombstone on disk. The backtraces/register contents are garbage in the tombstone (because it’s from where abort() was called in the sanitizer runtime), but it has logcat and memory mappings and such.

Also, tombstones get special handling on Android as they’re a crash. For example, you can see the crashes for an app using the ApplicationExitInfo API. This is not the case for exit().

2 Likes

Just a thought:

Would it be worthwhile to document this in either sanitizer_flags.inc, or in the external documentation?

I have been a user of the sanitizers for a good number of years, but didn’t ever considering checking my mac crash logs for better info on the problems. It may be nice to advertise this to the user.

I’m happy to follow up with a PR if we think this is a good idea. Any thoughts on where it might live? I don’t see an obvious .rst that corresponds to ‘common sanitizer behavior’.

Minimally, I could put a one liner comment in sanitizer_flags.inc describing why it’s done internally. That could help other devs, but is less helpful to the public at large.

1 Like