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 5 commits into
base: develop
Choose a base branch
from
Open

Make getenv thread-safe #191

wants to merge 5 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

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 Flamefire force-pushed the get-env-thread branch 8 times, most recently from 1af7cff to 96cecd0 Compare December 4, 2024 16:16
Using `bash` puts `/mingw64/bin` first in the path but the compiler from
`/c/mingw64/bin` is used.
This leads to errors running the tests: "Exit code 0xc0000139" (DLL issue)
which are related to the use of `thread_local`.
Using the powershell works in all cases.
@Flamefire Flamefire force-pushed the get-env-thread branch 2 times, most recently from 4e7d4b7 to d96b3cf Compare December 5, 2024 17:58
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