[all-commits] [llvm/llvm-project] c82f3c: [scudo] Add StackDepot lock to enable/disable. (#7...

Evgenii Stepanov via All-commits all-commits at lists.llvm.org
Mon Jan 29 14:22:37 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c82f3caf5683a443692162d9fbebc31019af7ce8
      https://github.com/llvm/llvm-project/commit/c82f3caf5683a443692162d9fbebc31019af7ce8
  Author: Evgenii Stepanov <eugeni.stepanov at gmail.com>
  Date:   2024-01-29 (Mon, 29 Jan 2024)

  Changed paths:
    M compiler-rt/lib/scudo/standalone/combined.h
    M compiler-rt/lib/scudo/standalone/stack_depot.h

  Log Message:
  -----------
  [scudo] Add StackDepot lock to enable/disable. (#79670)

Scudo grabs all allocator locks in a pthread_atfork before the fork, and releases them after. This allows malloc to be used in a fork child of a multithreaded process, which is expressly forbidden by the standard, but very widely used. For example, Android's init uses std::string after fork when spawning services in android::init::EnterNamespaces and other places.

Any lock that is necessary to serve an allocator call must be handled this way. Otherwise there is a possibility that the lock is held during the call to fork, which results in it being held forever in the child process, and the next operation that needs it deadlocks.




More information about the All-commits mailing list