Calling setenv during init is unsafe for multithreaded programs
johnwheffner opened this issue · 1 comments
johnwheffner commented
We have an application that runs on Linux and uses the AWS C++ SDK. It's a multithreaded application, and for reasons it initializes the AWS SDK (and transitively the aws-c-io library) after there are already a number of threads executing. Some of these threads may at times call getenv
. We get crashes in these getenv
calls if they occur concurrently with aws-c-io init, which calls setenv
in aws_tls_init_static_state
. According to the glibc docs, "Modifications of environment variables are not allowed in multi-threaded programs."
It would be better to avoid the setenv
call.