This is an archive of the discontinued LLVM Phabricator instance.

Stop tracking atexit/__cxa_atexit/pthread_atfork allocations in LSan/NetBSD
ClosedPublic

Authored by krytarowski on Sep 8 2019, 9:23 AM.

Details

Summary

The atexit(3) and __cxa_atexit() calls allocate internally memory and free on exit,
after executing all callback. This causes false positives as DoLeakCheck() is called
from the atexit handler. In the LSan/ASan tests there are strict checks triggering
false positives here.

Intercept all atexit(3) and __cxa_atexit() calls and disable LSan when calling the
real functions.

Stop tracing allocations in pthread_atfork(3) funtions, as there are performed
internal allocations that are not freed for the time of running StopTheWorld()
code. This avoids false-positives.

The same changes have to be replicated in the ASan and LSan runtime.

Non-NetBSD OSs are not tested and this code is restricted to NetBSD only.

Diff Detail

Repository
rL LLVM

Event Timeline

krytarowski created this revision.Sep 8 2019, 9:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 8 2019, 9:23 AM
vitalybuka added inline comments.
lib/asan/asan_interceptors.cpp
585 ↗(On Diff #219272)

ASAN_INTERCEPT_ATEXIT ?

599 ↗(On Diff #219272)

ASAN_INTERCEPT_.... ?

lib/lsan/lsan_interceptors.cpp
349 ↗(On Diff #219272)

why only NETBSD in lsan for __cxa_atexit

krytarowski edited the summary of this revision. (Show Details)
  • apply changes from review
krytarowski marked an inline comment as done.Sep 16 2019, 5:44 PM
krytarowski added inline comments.
lib/lsan/lsan_interceptors.cpp
349 ↗(On Diff #219272)

!NetBSD not tested. Feel free to test it and enable it once the change will land.

krytarowski marked 2 inline comments as done.Sep 16 2019, 5:45 PM

Tests?

Actually these problems are triggered by the existing tests and any other real non-trivial application used with LSan/NetBSD.

krytarowski added a comment.EditedSep 20 2019, 5:07 PM

With these patches included there are still ~3 failing tests and I will mark them as XFAIL for now.

LSan/Linux tests can be reused on NetBSD almost fully, but I will keep it for another iteration.

vitalybuka accepted this revision.Sep 20 2019, 5:35 PM
This revision is now accepted and ready to land.Sep 20 2019, 5:35 PM
This revision was automatically updated to reflect the committed changes.

This commit causes test failures (at least) on the SystemZ build bots:

[7/99] Running lint check for sanitizer sources...
FAILED: projects/compiler-rt/lib/CMakeFiles/SanitizerLintCheck 
[...]
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/projects/compiler-rt/lib/lsan/lsan_interceptors.cpp:378:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/projects/compiler-rt/lib/asan/asan_interceptors.cpp:610:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
jsji added a subscriber: jsji.Sep 22 2019, 9:09 AM

This commit causes test failures (at least) on the SystemZ build bots:

[7/99] Running lint check for sanitizer sources...
FAILED: projects/compiler-rt/lib/CMakeFiles/SanitizerLintCheck 
[...]
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/projects/compiler-rt/lib/lsan/lsan_interceptors.cpp:378:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/projects/compiler-rt/lib/asan/asan_interceptors.cpp:610:  Lines should be <= 80 characters long  [whitespace/line_length] [2]

Also failed on PowerPC. Should be fixed with https://reviews.llvm.org/rL372511.