1. Mar 26, 2020
    • Dmitry Vyukov's avatar
      tsan: fix leak of ThreadSignalContext for fibers · d8a0f76d
      Dmitry Vyukov authored
      When creating and destroying fibers in tsan a thread state
      is created and destroyed. Currently, a memory mapping is
      leaked with each fiber (in __tsan_destroy_fiber).
      This causes applications with many short running fibers
      to crash or hang because of linux vm.max_map_count.
      
      The root of this is that ThreadState holds a pointer to
      ThreadSignalContext for handling signals. The initialization
      and destruction of it is tied to platform specific events
      in tsan_interceptors_posix and missed when destroying a fiber
      (specifically, SigCtx is used to lazily create the
      ThreadSignalContext in tsan_interceptors_posix). This patch
      cleans up the memory by inverting the control from the
      platform specific code calling the generic ThreadFinish to
      ThreadFinish calling a platform specific clean-up routine
      after finishing a thread.
      
      The relevant code causing the leak with fibers is the fiber destruction:
      
      void FiberDestroy(ThreadState *thr, uptr pc, ThreadState *fiber) {
        FiberSwitchImpl(thr, fiber);
        ThreadFinish(fiber);
        FiberSwitchImpl(fiber, thr);
        internal_free(fiber);
      }
      
      I would appreciate feedback if this way of fixing the leak is ok.
      Also, I think it would be worthwhile to more closely look at the
      lifecycle of ThreadState (i.e. it uses no constructor/destructor,
      thus requiring manual callbacks for cleanup) and how OS-Threads/user
      level fibers are differentiated in the codebase. I would be happy to
      contribute more if someone could point me at the right place to
      discuss this issue.
      
      Reviewed-in: https://reviews.llvm.org/D76073
      Author: Florian (Florian)
      d8a0f76d
    • Dmitry Vyukov's avatar
      compiler-rt: allow golang race detector to run on musl-c · 5f149ef5
      Dmitry Vyukov authored
      tsan while used by golang's race detector was not working on alpine
      linux, since it is using musl-c instead of glibc. Since alpine is very
      popular distribution for container deployments, having working race
      detector would be nice. This commits adds some ifdefs to get it working.
      
      It fixes https://github.com/golang/go/issues/14481 on golang's issue tracker.
      
      Reviewed-in: https://reviews.llvm.org/D75849
      Author: graywolf-at-work (Tomas Volf)
      5f149ef5
    • Pavel Labath's avatar
      [lldb] add lit.local.cfg for breakpad tests · c7267539
      Pavel Labath authored
      The reason is to add .yaml as a valid test suffix. The test folder
      contains one yaml file, which wasn't being run because of that.
      
      Unsurprisingly the test fails, but this was not because the underlying
      functionality was broken, but rather because the test was setup
      incorrectly (most likely due to overly aggressive simplification of the
      test data on my part).
      
      Therefore this patch also tweaks the test inputs in order to test what
      they are supposed to test, and also updates some other breakpad tests
      (because they depend on the same inputs as this one) to be more
      realistic -- specifically it avoids putting symbols to the first page of
      the module, as that's where normally the COFF header would reside.
      c7267539
  2. Mar 25, 2020