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

std.process execve depends on environ pointer not changing #10574

Open
schveiguy opened this issue Dec 5, 2024 · 0 comments
Open

std.process execve depends on environ pointer not changing #10574

schveiguy opened this issue Dec 5, 2024 · 0 comments

Comments

@schveiguy
Copy link
Member

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.

schveiguy added a commit to schveiguy/phobos that referenced this issue Dec 5, 2024
schveiguy added a commit to schveiguy/phobos that referenced this issue Dec 5, 2024
schveiguy added a commit to schveiguy/phobos that referenced this issue Dec 5, 2024
schveiguy added a commit to schveiguy/phobos that referenced this issue Dec 7, 2024
dlang-bot pushed a commit that referenced this issue Dec 7, 2024
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

No branches or pull requests

1 participant