[compiler-rt] [TSan] Add interceptors for flockfile, ftrylockfile, funlockfile (PR #203470)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 29 07:48:58 PDT 2026
krzysdz wrote:
I have a couple questions (maybe not to the author of this PR, but someone who knows ThreadSanitizer better):
- Can `MutexPreLock`/`MutexPostLock`/`MutexUnlock` be used without `MutexCreate`?
- Is `MutexFlagNotStatic` used correctly? The `FILE *` used as _mutex_ may have static storage duration (e.g. [`stdin`/`stdout`/`stderr`](https://elixir.bootlin.com/glibc/glibc-2.43/source/libio/stdfiles.c#L35-L54)).
https://github.com/llvm/llvm-project/blob/d5c982fb0ead0c8c9b8ac4bdf332a6084465a632/compiler-rt/include/sanitizer/tsan_interface.h#L46-L50
- `flockfile`/`ftrylockfile`/`funlockfile` on `FILE *` implement a recursive mutex - the owning thread can lock it multiple times ([docs](https://pubs.opengroup.org/onlinepubs/9799919799/functions/flockfile.html); glibc implementation [1](https://elixir.bootlin.com/glibc/glibc-2.43/source/stdio-common/flockfile.c#L22-L29), [2](https://elixir.bootlin.com/glibc/glibc-2.43/source/sysdeps/nptl/stdio-lock.h#L26-L84)). Doesn't this require `MutexFlagRecursiveLock`?
https://github.com/llvm/llvm-project/pull/203470
More information about the llvm-commits
mailing list