[all-commits] [llvm/llvm-project] 776027: [lsan] Don't crash on ThreadRegistry::threads_ dat...

Vitaly Buka via All-commits all-commits at lists.llvm.org
Mon Apr 17 15:34:03 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 776027277818af1a2672dc396cdd64d79dacf495
      https://github.com/llvm/llvm-project/commit/776027277818af1a2672dc396cdd64d79dacf495
  Author: Vitaly Buka <vitalybuka at google.com>
  Date:   2023-04-17 (Mon, 17 Apr 2023)

  Changed paths:
    M compiler-rt/lib/lsan/lsan.cpp
    M compiler-rt/lib/lsan/lsan_common_mac.cpp
    M compiler-rt/lib/lsan/lsan_linux.cpp
    M compiler-rt/lib/lsan/lsan_thread.cpp
    M compiler-rt/lib/lsan/lsan_thread.h
    A compiler-rt/test/lsan/TestCases/thread_context_crash.cpp
    M compiler-rt/test/lsan/lit.common.cfg.py

  Log Message:
  -----------
  [lsan] Don't crash on ThreadRegistry::threads_ data race

Comment "No lock needed" in CurrentThreadContext was wrong.
Concurent ThreadRegistry::CreateThread can resize and relocate
ThreadRegistry::threads_ the same time CurrentThreadContext reads it.

To mitigate lock cost we store ThreadContext* instead of tid in
THREADLOCAL cache, we can tid from the ThreadContext*.

Reviewed By: kstoimenov, MaskRay

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




More information about the All-commits mailing list