[PATCH] D18132: [tsan] Detect uses of uninitialized, destroyed and invalid mutexes

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 13 06:51:14 PDT 2016


kubabrecka created this revision.
kubabrecka added reviewers: dvyukov, glider, samsonov, kcc.
kubabrecka added subscribers: llvm-commits, zaks.anna, filcab.

Currently, calling `pthread_mutex_lock` on a destroyed (or uninitialized or completely invalid) mutex will silently continue, without any TSan reports.  This is because the function will return `EINVAL` in these cases.  However, it's extremely uncommon to correctly handle failure return values from `pthread_mutex_lock`.  In fact, I don't remember ever seeing code that even checks the return value from `pthread_mutex_lock`.

This patch adds a new TSan report type, `ReportTypeMutexInvalidAccess`, which is triggered when `pthread_mutex_lock` or `pthread_mutex_unlock` returns `EINVAL` (this means the mutex is invalid, uninitialized or already destroyed).

http://reviews.llvm.org/D18132

Files:
  lib/sanitizer_common/sanitizer_common_interceptors.inc
  lib/tsan/rtl/tsan_debugging.cc
  lib/tsan/rtl/tsan_interceptors.cc
  lib/tsan/rtl/tsan_report.cc
  lib/tsan/rtl/tsan_report.h
  lib/tsan/rtl/tsan_rtl.h
  lib/tsan/rtl/tsan_rtl_mutex.cc
  lib/tsan/rtl/tsan_suppressions.cc
  test/tsan/mutex_lock_destroyed.cc

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18132.50550.patch
Type: text/x-patch
Size: 6192 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160313/342b1b53/attachment.bin>


More information about the llvm-commits mailing list