This is an archive of the discontinued LLVM Phabricator instance.

[GWP-ASan] Fix atfork handlers being installed multiple times in tests
ClosedPublic

Authored by hctim on Dec 9 2022, 11:10 AM.

Details

Summary

We incorrectly install the atfork handlers multiple times in the test
harness, tracked down to the default parameter used by
CheckLateInitIsOK. This manifested in a hang if running the tests with
--gtest_repeat={>=2} as the atfork handler ran multiple times, causing
double-lock and double-unlock, which on my machine hung.

Add a check-fail for this case as well to prevent this from happening
again (it was difficult to track down and is an easy mistake to make).

Diff Detail

Event Timeline

hctim created this revision.Dec 9 2022, 11:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 9 2022, 11:10 AM
Herald added a subscriber: Enna1. · View Herald Transcript
hctim requested review of this revision.Dec 9 2022, 11:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 9 2022, 11:10 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
hctim updated this revision to Diff 486071.Jan 3 2023, 1:48 PM

Rebased. vitalybuka@ / eugenis@ PTAL.

vitalybuka added inline comments.Jan 4 2023, 11:49 AM
compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_posix.cpp
101

I would prefer just return instead of CHECK here?

109–110

or even better this way if function local statics are supported

compiler-rt/lib/gwp_asan/tests/late_init.cpp
22 ↗(On Diff #486071)

then you don't need this change

hctim marked 3 inline comments as done.Jan 10 2023, 10:01 AM
hctim added inline comments.
compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_posix.cpp
109–110

neat, missed this trick :)

hctim updated this revision to Diff 487864.Jan 10 2023, 10:01 AM
hctim marked an inline comment as done.

update w/ vitaly's suggestions

hctim updated this revision to Diff 487871.Jan 10 2023, 10:15 AM

yeah, unfortunately no bueno on the "run only once by assigning to a static var" method. It requires cxa guards for static initialization, and we don't link against a cxx runtime. Falling back to the less pretty method.

This revision was not accepted when it landed; it landed in state Needs Review.Jan 10 2023, 10:16 AM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.