Skip to content

[SR-6420] Ensure that the pthread_key is initialised once #1325

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
Nov 20, 2017
Merged

[SR-6420] Ensure that the pthread_key is initialised once #1325

merged 1 commit into from
Nov 20, 2017

Conversation

alblue
Copy link
Contributor

@alblue alblue commented Nov 17, 2017

No description provided.

@alblue
Copy link
Contributor Author

alblue commented Nov 17, 2017

@swift-ci please test

@parkera
Copy link
Contributor

parkera commented Nov 17, 2017

How are we calling _CFTSDInitialize more than once in the first place?

@alblue
Copy link
Contributor Author

alblue commented Nov 17, 2017

The table is a thread-local, so it is called once per thread. If you submit many async dispatch blocks that trigger a CF code path, this table gets assigned as a thread local per dispatch worker thread.

@alblue
Copy link
Contributor Author

alblue commented Nov 17, 2017

Need to check under the load test that found this problem that it resolves the issue. Please hold off merging until then.

@parkera
Copy link
Contributor

parkera commented Nov 17, 2017

If we're calling __CFInitialize more than once we have serious problems. That is once per process start.

@parkera
Copy link
Contributor

parkera commented Nov 17, 2017

And that is the only place we call the _CFTSDInitialize function...

@alblue
Copy link
Contributor Author

alblue commented Nov 17, 2017

You’ll note that there is a call to this inside the same file on line 666 which is the one causing the duplicate calls.

@parkera
Copy link
Contributor

parkera commented Nov 17, 2017

You're right; that's different than the Darwin Foundation.

I think the right solution here is actually just to delete the call from CFPlatform.c.

@parkera
Copy link
Contributor

parkera commented Nov 17, 2017

That is unless somehow this call happens before __CFInitialize, but I hope not. That's supposed to be first.

@alblue
Copy link
Contributor Author

alblue commented Nov 17, 2017

Will have a look next week to see why the call is there. It may have been added because the CFInitialize wasn’t being called first, and so this was added as a workaround. Or it may be unnecessary. We have a test case that can verify either solution so will get to that on Monday.

@alblue
Copy link
Contributor Author

alblue commented Nov 20, 2017

@parkera the change (adding the initialize) was dropped into a mega-drop in a455cde by @phausler last year. Given that this patch allows the call to happen at most once per process, I'm going to merge this as is, and then maybe @phausler knows why the call to adding the initialize was required subsequently.

@alblue
Copy link
Contributor Author

alblue commented Nov 20, 2017

@swift-ci please test and merge

@swift-ci swift-ci merged commit f962c37 into swiftlang:master Nov 20, 2017
@parkera
Copy link
Contributor

parkera commented Nov 27, 2017

I'm not happy at all about merging this without getting to the root cause.

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.

3 participants