Skip to content
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

Make getenv thread-safe #191

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open

Make getenv thread-safe #191

wants to merge 3 commits into from

Conversation

Flamefire
Copy link
Collaborator

In order to return a non-owning pointer without memory leaks the function needs to use a static variable.
When calling it from multiple threads there is a data race during the assignment (and conversion) to this variable.
Fix by making it thread_local.

Fixes #189

Flamefire and others added 3 commits November 29, 2024 10:10
In order to return a non-owning pointer without memory leaks the
function needs to use a static variable.
When calling it from multiple threads there is a data race during the
assignment (and conversion) to this variable.
Fix by making it `thread_local`.

Fixes #189
MinGW seems to have a bug with function-local thread_local variables.
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.

GetEnv is hazardous when used in multiple threads
1 participant