This is an archive of the discontinued LLVM Phabricator instance.

[Sanitizers] Unify the semantics and usage of "exitcode" runtime flag across all sanitizers.
ClosedPublic

Authored by samsonov on Aug 18 2015, 3:02 PM.

Details

Summary

Merge "exitcode" flag from ASan, LSan, TSan and "exit_code" from MSan
into one entity. Additionally, make sure sanitizer_common now uses the
value of common_flags()->exit_code when dying on error, so that this
flag will automatically work for other sanitizers (UBSan and DFSan) as
well.

    • User-visible changes ***
  1. "exit_code" MSan runtime flag is removed in favor of "exitcode"
  2. asan_set_error_exit_code() and msan_set_exit_code() functions are removed. With few exceptions, we don't support changing runtime flags during program execution - we can't make them thread-safe. The users should use __sanitizer_set_death_callback() that would call _exit() with proper exit code instead.
  3. Plugin tools (LSan and UBSan) now inherit the exit code of the parent tool. In particular, this means that ASan would now crash the program with exit code "1" instead of "23" if it detects leaks.

Diff Detail

Repository
rL LLVM

Event Timeline

samsonov updated this revision to Diff 32460.Aug 18 2015, 3:02 PM
samsonov retitled this revision from to [Sanitizers] Unify the semantics and usage of "exitcode" runtime flag across all sanitizers..
samsonov updated this object.
samsonov added reviewers: kcc, eugenis.
samsonov added a subscriber: llvm-commits.
eugenis added inline comments.Aug 18 2015, 3:10 PM
lib/msan/msan_linux.cc
159 ↗(On Diff #32460)

I think you still need MsanDie to actually kill the process.

samsonov added inline comments.Aug 18 2015, 3:12 PM
lib/msan/msan_linux.cc
159 ↗(On Diff #32460)

MsanDie is called as InternalDieCallback() inside __sanitizer::Die(). Then __sanitizer::Die() would actually proceed to kill the process.

eugenis accepted this revision.Aug 18 2015, 3:14 PM
eugenis edited edge metadata.

LGTM

This revision is now accepted and ready to land.Aug 18 2015, 3:14 PM
samsonov updated this revision to Diff 32581.Aug 19 2015, 10:59 AM
samsonov edited edge metadata.

Restore MSAN_OPTIONS=exit_code and mark it as deprecated.

This revision was automatically updated to reflect the committed changes.