This is an archive of the discontinued LLVM Phabricator instance.

[asan] set program exit code in keep-going mode
Needs RevisionPublic

Authored by Enna1 on Aug 28 2023, 5:04 AM.

Details

Summary

Set program exit code in keep-going mode if asan reports errors.
We already have this for msan and hwasan, make the behavior of asan consistent with msan and hwasan.

Diff Detail

Event Timeline

Enna1 created this revision.Aug 28 2023, 5:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 28 2023, 5:04 AM
Enna1 published this revision for review.Aug 28 2023, 7:23 AM
Enna1 added reviewers: vitalybuka, eugenis, kstoimenov.
Enna1 added a subscriber: MTC.
Herald added a project: Restricted Project. · View Herald TranscriptAug 28 2023, 7:23 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
MaskRay accepted this revision.Aug 28 2023, 1:23 PM
MaskRay added a subscriber: MaskRay.

Looks reasonable and check-asan passes on Linux x86-64. It's best to wait for an existing reviewer.

compiler-rt/lib/asan/asan_internal.h
137

Move this before asan_init_is_running to be consistant with msan/hwasan.

compiler-rt/lib/asan/asan_rtl.cpp
319

replace the nested if with && and omit braces

This revision is now accepted and ready to land.Aug 28 2023, 1:23 PM
MaskRay added inline comments.Aug 28 2023, 1:26 PM
compiler-rt/lib/asan/asan_rtl.cpp
77

move below asan_init_is_running

vitalybuka requested changes to this revision.EditedAug 28 2023, 1:33 PM

What is tsan behavior?
And ubsan?

This sounds strange to me.

Intended usecase is to run but log errors.
But In multi-process environment failing process at the end will likely fails all parents.

So I'd rather reconsider behavior of msan and hwasan,

This revision now requires changes to proceed.Aug 28 2023, 1:33 PM
Enna1 added a comment.EditedAug 28 2023, 9:09 PM

What is tsan behavior?
And ubsan?

This sounds strange to me.

Intended usecase is to run but log errors.
But In multi-process environment failing process at the end will likely fails all parents.

So I'd rather reconsider behavior of msan and hwasan,

For tsan, tsan defaults halt_on_error to false and tsan implements this in _exit interceptor.

For ubsan, I didn't find where ubsan set exitcode explicitly.

Actually, asan and msan also have its _exit interceptor, https://reviews.llvm.org/rGfdfb2ade8fd158b4df33b1d677e1de4737582324

  • in asan _exit interceptor, exitcode is set only when leaks are detected.
  • in msan _exit interceptor, exitcode is always set to 0.
  • and hwasan doesn't implement _exit interceptor.

Maybe we should remove current InstallAtExitHandler in asan/msan/hwasan and unify them to set exitcode in _exit interceptor.

My understand the usecase of keep-going mode is to run once and find bugs as much as possible.
We need a way to check if any bug is detected without manually greping the log, so I think rely on exitcode is reasonable.

Enna1 added a comment.Sep 17 2023, 9:34 PM

gentle ping