Skip to content

Conversation

@DanBlackwell
Copy link

There is a common library that interposes the write call, and is interposed itself. When running with TSAN_OPTIONS=verbosity=(1|2), this leads to a thread locking itself, resulting in a hang.

This patch adds a new flag lock_during_write to TSan that allows interceptors to be bypassed during calls to write when set. The flag can be inherited by children, or not, depending on the value.

rdar://157565672

…lock

There is a common library that interposes the write call, and is interposed itself. When running with TSAN_OPTIONS=verbosity=(1|2), this leads to a thread locking itself, resulting in a hang.

This patch adds a new flag `lock_during_write` to TSan that allows interceptors to be bypassed during calls to write when set. The flag can be inherited by children, or not, depending on the value.

rdar://157565672
(cherry picked from commit c2c6fed)
There are currently build errors when checking the TSan Go runtime due to the implementation of this flag:

```
 ../rtl/tsan_rtl.cpp:46:11: error: no member named 'cur_thread_init' in namespace '__tsan'
    46 |   __tsan::cur_thread_init()->in_internal_write_call = value;
       |           ^~~~~~~~~~~~~~~
 ../../sanitizer_common/sanitizer_mac.cpp:109:38: error: redefinition of '__tsan_set_in_internal_write_call'
   109 | SANITIZER_WEAK_ATTRIBUTE extern void __tsan_set_in_internal_write_call(
       |                                      ^
 ../rtl/tsan_rtl.cpp:45:13: note: previous definition is here
    45 | extern void __tsan_set_in_internal_write_call(bool value) {
       |             ^
```

This patch guards all changes related to the flag behind `!SANITIZER_GO` to avoid these errors occurring.

(cherry picked from commit 79c8397)
This test is currently failing on ios-sim. This patch follows other sanitizer tests that use DYLD_INSERT_LIBRARIES and marks itself unsupported on ios platforms.

rdar://162287951
(cherry picked from commit ddd5075)
@DanBlackwell
Copy link
Author

@swift-ci please test

@DanBlackwell DanBlackwell merged commit f5781a0 into swiftlang:stable/21.x Oct 29, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant