Skip to content

Conversation

@adierking
Copy link
Contributor

There's a quirk on Windows where exiting the process will still run fiber-local
storage destructors for the thread that called ExitProcess() (but only for that
thread). pthreads-based platforms don't call any key destructors on exit, and
_libdispatch_tsd_cleanup() assumes this. So, on Windows, calling exit() from a
queue thread will trigger the fatal error in _dispatch_frame_cleanup().

Implement a reliable method of detecting whether the process is exiting, and if
it is, ignore calls to _libdispatch_tsd_cleanup().

@adierking
Copy link
Contributor Author

cc @MadCoder @compnerd

There's a quirk on Windows where exiting the process will still run fiber-local
storage destructors for the thread that called ExitProcess() (but only for that
thread). pthreads-based platforms don't call any key destructors on exit, and
_libdispatch_tsd_cleanup() assumes this. So, on Windows, calling exit() from a
queue thread will trigger the fatal error in _dispatch_frame_cleanup().

Implement a reliable method of detecting whether the process is exiting, and if
it is, ignore calls to _libdispatch_tsd_cleanup().
Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite a clever approach. Thanks for adding the comments explaining what is going on.

@compnerd
Copy link
Member

@swift-ci please test

@MadCoder MadCoder merged commit ba3933d into swiftlang:master Jun 29, 2018
@adierking adierking deleted the fls branch December 2, 2018 00:33
ktopley-apple pushed a commit that referenced this pull request Dec 6, 2018
Ignore Windows FLS destructors during process exit

Signed-off-by: Kim Topley <ktopley@apple.com>
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.

4 participants