[all-commits] [llvm/llvm-project] fb32a6: [sanitizer] Move {, __}pthread_mutex_{lock, unlock} ...

Fangrui Song via All-commits all-commits at lists.llvm.org
Wed Jan 4 12:04:32 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fb32a69855341630a7084364c66083264e1d18bf
      https://github.com/llvm/llvm-project/commit/fb32a69855341630a7084364c66083264e1d18bf
  Author: Fangrui Song <i at maskray.me>
  Date:   2023-01-04 (Wed, 04 Jan 2023)

  Changed paths:
    M compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
    M compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
    M compiler-rt/lib/tsan/rtl-old/tsan_interceptors_posix.cpp
    M compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp

  Log Message:
  -----------
  [sanitizer] Move {,__}pthread_mutex_{lock,unlock} interceptors to tsan

These interceptors are pure forwarders for other sanitizers. Move them beside
tsan-specific pthread_mutex_{trylock,timedlock} interceptors.

While here, guard `__pthread_mutex_{lock,unlock}` (D46793) under `#if !__GLIBC_PREREQ(2, 34)`.

In glibc>=2.34 [1], `__pthread_mutex_{lock,unlock}` only have non-default-version definitions
(unversioned `__pthread_mutex_lock` causes a linker error. Program preloading is not expected).
In glibc>=2.36 [2], `dlsym(RTLD_NEXT, "__pthread_mutex_lock")` returns nullptr, so the interceptor won't work.

Fix https://github.com/llvm/llvm-project/issues/59820

[1]: https://sourceware.org/git/?p=glibc.git;a=commit;h=99f841c441feeaa9a3d97fd91bb3d6ec8073c982
[2]: https://sourceware.org/git/?p=glibc.git;a=commit;h=efa7936e4c91b1c260d03614bb26858fbb8a0204

Reviewed By: melver, vitalybuka

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




More information about the All-commits mailing list