Skip to content

Commit ec67520

Browse files
authored
FreeBSD: Set TSD to NULL when maximum pthread dtor iterations reached (#5273)
On FreeBSD, libthr emits debug message to stderr if a TSD is non-null after `PTHREAD_DESTRUCTOR_ITERATIONS` of dtor getting called. Currently, although we skipped setting the TSD to `CF_TSD_BAD_PTR` like other platforms, the TSD still remains non-null after max iterations of dtor calls.
1 parent 94ef6ab commit ec67520

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Sources/CoreFoundation/CFPlatform.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,9 @@ static void __CFTSDFinalize(void *arg) {
961961

962962
// FreeBSD libthr emits debug message to stderr if there are leftover nonnull TSD after PTHREAD_DESTRUCTOR_ITERATIONS
963963
// On this platform, the destructor will never be called again, therefore it is unneccessary to set the TSD to CF_TSD_BAD_PTR
964-
#if !defined(__FreeBSD__)
964+
#if defined(__FreeBSD__)
965+
__CFTSDSetSpecific(NULL);
966+
#else
965967
// Now if the destructor is called again we will take the shortcut at the beginning of this function.
966968
__CFTSDSetSpecific(CF_TSD_BAD_PTR);
967969
#endif

0 commit comments

Comments
 (0)