-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Avoid runtime crashes by removing undefined behavior. #1560
Conversation
@@ -628,6 +628,7 @@ static void *__CFTSDGetSpecific() { | |||
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI | |||
return pthread_getspecific(__CFTSDIndexKey); | |||
#elif DEPLOYMENT_TARGET_LINUX | |||
__CFTSDInitialize(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this actually belongs here:
where we can probably just remove the requirement for DEPLOYMENT_RUNTIME_SWIFT
and make it DEPLOYMENT_TARGET_LINUX
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took me bit to validate, but this works and I agree its best suited. I just updated the pull request, please take a look.
I think you have the commits for your other PR merged into this one. Can you separate them? |
@swift-ci please test |
1 similar comment
@swift-ci please test |
@swift-ci please test and merge |
From pthread docs:
"The effect of calling pthread_getspecific() or pthread_setspecific() with a key value not obtained from pthread_key_create() or after key has been deleted with pthread_key_delete() is undefined."
On some Linux flavors this results in getspecific returning uninitialized pointer with results in runtime crashes after dereferencing invalid memory.
Also NULL format for fprintf is invalid and results on crashes when calling CFShow.