Skip to content

[Windows] Fix thread local storage cleanup #2902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions CoreFoundation/Base.subproj/CFPlatform.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,16 +663,6 @@ CF_PRIVATE void __CFTSDWindowsCleanup() {
FlsFree(__CFTSDIndexKey);
}

// Called for each thread as it exits, on Windows only
CF_PRIVATE void __CFFinalizeWindowsThreadData() {
// Normally, this should call the finalizer several times to emulate the behavior of pthreads on Windows. However, a few bugs keep us from doing this:
// <rdar://problem/8989063> REGRESSION(CF-610-CF-611): Crash closing Safari in BonjourDB destructor (Windows)
// <rdar://problem/9326814> SyncUIHandler crashes after conflict is resolved and we do SyncNow
// and a bug in dispatch keeps us from using pthreadsWin32 directly, because it does not deal with the case of a dispatch_async happening during process exit (it attempts to create a thread, but that is illegal on Win32 and causes a hang).
// So instead we just finalize once, which is the behavior pre-Airwolf anyway
__CFTSDFinalize(TlsGetValue(__CFTSDIndexKey));
}

#else

static _CFThreadSpecificKey __CFTSDIndexKey;
Expand Down
3 changes: 0 additions & 3 deletions CoreFoundation/Base.subproj/CFRuntime.c
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,6 @@ CF_PRIVATE void __CFTSDInitialize(void);
#if TARGET_OS_WIN32
// From CFPlatform.c
CF_PRIVATE void __CFTSDWindowsCleanup(void);
CF_PRIVATE void __CFFinalizeWindowsThreadData(void);
#endif

#if TARGET_OS_MAC
Expand Down Expand Up @@ -1352,8 +1351,6 @@ int DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID pReserved ) {
// do these last
if (cfBundle) CFRelease(cfBundle);
__CFStringCleanup();
} else if (dwReason == DLL_THREAD_DETACH) {
__CFFinalizeWindowsThreadData();
}
return TRUE;
}
Expand Down