This is an archive of the discontinued LLVM Phabricator instance.

[hwasan] Support malloc in atfork.
ClosedPublic

Authored by eugenis on Aug 13 2021, 5:42 PM.

Details

Summary

Before this change we were locking the StackDepot in the fork()
interceptor. This results in a deadlock when allocator functions are
used in a pthread_atfork() callback.

Instead, set up a pthread_atfork() callback at init that locks/unlocks
both StackDepot and the allocator. Since our callback is set up very
early, the pre-fork callback is executed late, and both post-fork ones
are executed early, which works perfect for us.

Diff Detail

Event Timeline

eugenis requested review of this revision.Aug 13 2021, 5:42 PM
eugenis created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptAug 13 2021, 5:42 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript

(+llvm-commits)

pcc accepted this revision.Aug 13 2021, 7:00 PM

LGTM

This revision is now accepted and ready to land.Aug 13 2021, 7:00 PM
eugenis updated this revision to Diff 367030.Aug 17 2021, 3:07 PM

rebase (-formatting changes), remove the fork interceptor completely

This revision was landed with ongoing or failed builds.Aug 17 2021, 3:30 PM
This revision was automatically updated to reflect the committed changes.