[all-commits] [llvm/llvm-project] bd301a: [BOLT] Fix concurrent hash table modification in t...

Michał Chojnowski via All-commits all-commits at lists.llvm.org
Thu Jul 7 04:29:51 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bd301a418bf2a866c7c17a5cdc82a1d7d13e156f
      https://github.com/llvm/llvm-project/commit/bd301a418bf2a866c7c17a5cdc82a1d7d13e156f
  Author: Michał Chojnowski <michal.chojnowski at scylladb.com>
  Date:   2022-07-07 (Thu, 07 Jul 2022)

  Changed paths:
    M bolt/runtime/instr.cpp

  Log Message:
  -----------
  [BOLT] Fix concurrent hash table modification in the instrumentation runtime

`__bolt_instr_data_dump()` does not lock the hash tables when iterating
over them, so the iteration can happen concurrently with a modification
done in another thread, when the table is in an inconsistent state. This
also has been observed in practice, when it caused a segmentation fault.

We fix this by locking hash tables during iteration. This is done by taking
the lock in `forEachElement()`.
The only other site of iteration, `resetCounters()`, has been correctly
locking the table even before this patch. This patch removes its `Lock`
because the lock is now taken in the inner `forEachElement()`.

Reviewed By: maksfb, yota9

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




More information about the All-commits mailing list