[all-commits] [llvm/llvm-project] 8a570a: [hwasan] Support malloc in atfork.

Evgenii Stepanov via All-commits all-commits at lists.llvm.org
Tue Aug 17 15:30:15 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8a570a873b25af4c718a16caa214b4f7bc14e6d6
      https://github.com/llvm/llvm-project/commit/8a570a873b25af4c718a16caa214b4f7bc14e6d6
  Author: Evgenii Stepanov <eugenis at google.com>
  Date:   2021-08-17 (Tue, 17 Aug 2021)

  Changed paths:
    M compiler-rt/lib/hwasan/hwasan.cpp
    M compiler-rt/lib/hwasan/hwasan.h
    M compiler-rt/lib/hwasan/hwasan_allocator.cpp
    M compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
    M compiler-rt/lib/hwasan/hwasan_interceptors.cpp
    M compiler-rt/lib/hwasan/hwasan_linux.cpp
    A compiler-rt/test/hwasan/TestCases/Linux/atfork.cpp

  Log Message:
  -----------
  [hwasan] Support malloc in atfork.

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.

Differential Revision: https://reviews.llvm.org/D108063




More information about the All-commits mailing list