std.process execve depends on environ pointer not changing · Issue #10574 · dlang/phobos (original) (raw)
Been running down a spurious failure in a work project.
Every so often a std.process.execute
fails on execve
. The error is EFAULT or Bad Address.
What is happening is that std.process is using the default environ
pointer when no environment is provided.
However, it stores this in a local pointer. And then later on uses that local pointer inside the child process.
The problem is that in the time between calling std.process.execute
(or something else) and the time the fork is run, the environ
pointer has changed (because e.g. someone added a new environment variable in another thread). Because environ
is C allocated, the old pointer is deallocated. In this case, the pointer points at unallocated memory, and the execve
fails.
Will be adding a fix shortly.