Skip to content

Refactor stub version of pthread key handling to avoid allocation. NFC - #15087

Merged
sbc100 merged 1 commit into
mainfrom
stub_tls_refactor
Sep 22, 2021
Merged

sbc100 merged 1 commit into
mainfrom
stub_tls_refactor

Conversation

@sbc100

@sbc100 sbc100 commented Sep 22, 2021

Copy link
Copy Markdown
Collaborator

This is needed by a followup PR (#15086) which improves our LSan
support. LSan wants to be able to call pthread_key_create during its
own startup and doesn't expect allocation to occur during this time:

extern "C" void __lsan_init() {

This method of using a static array of keys is also the one used
by musl so this seems like a reasonable implementation:

void *__pthread_tsd_main[PTHREAD_KEYS_MAX] = { 0 };

@sbc100
sbc100 requested review from aardappel and kripken September 22, 2021 00:25
@sbc100 sbc100 changed the title Refactor stub version of tls_key handling to avoid allocation. NFC Refactor stub version of pthread key handling to avoid allocation. NFC Sep 22, 2021
@sbc100
sbc100 requested a review from tlively September 22, 2021 00:47
@aardappel

Copy link
Copy Markdown
Collaborator

Hah, I seem to remember I wrote some of this horrible code because last time we determined we needed to have a variable maximum, is that not needed anymore?

@sbc100

sbc100 commented Sep 22, 2021

Copy link
Copy Markdown
Collaborator Author

Hah, I seem to remember I wrote some of this horrible code because last time we determined we needed to have a variable maximum, is that not needed anymore?

I have some memory of that too.. but based on the fact that all the tests pass... and musl has that limit internally.. this seems reasonable.

@sbc100
sbc100 merged commit 998ea6f into main Sep 22, 2021
@sbc100
sbc100 deleted the stub_tls_refactor branch September 22, 2021 04:01
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.

2 participants