Skip to content

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Jun 17, 2020

We fix some wrong assumptions regarding GetEnvironmentVariableW()s
return value; although the comment got it right, the implementation
did not.

We also attempt to improve our putenv() implementation. The problem
that the underlying _putenv() is not thread-safe is no longer an
issue, since there are mutexes in place. This fixes the ZTS part of
bug #66265.

However, calling _putenv() after SetEnvironmentVariable() causes
issues regarding empty strings as variable values, because _putenv()
does not support that (instead, it removes the variable from the
environment). Therefore we swap both calls.

@cmb69 cmb69 marked this pull request as draft June 17, 2020 14:10
We fix some wrong assumptions regarding `GetEnvironmentVariableW()`s
return value; although the comment got it right, the implementation
did not.

We also attempt to improve our `putenv()` implementation.  The problem
that the underlying `_putenv()` is not thread-safe is no longer an
issue, since there are mutexes in place.  This fixes the ZTS part of
bug #66265.

However, calling `_putenv()` after `SetEnvironmentVariable()` causes
issues regarding empty strings as variable values, because `_putenv()`
does not support that (instead, it removes the variable from the
environment).  Therefore we swap both calls.
@cmb69 cmb69 changed the title Call _wputenv_s() also in ZTS builds Fix getenv()/putenv() glitches on Windows Jun 22, 2020
@cmb69 cmb69 marked this pull request as ready for review June 22, 2020 20:48
efree(pe.putenv_string);
efree(pe.key);
free(keyw);
free(valw);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole code is a big mess and we fail to unlock in this branch.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I fixed the latter with 32257ac (PHP-7.4), and will have a look at cleaning up the code as soon as possible.

@cmb69 cmb69 marked this pull request as draft June 24, 2020 09:46
@krakjoe
Copy link
Member

krakjoe commented Aug 31, 2025

Closing as this has been marked draft for an extraordinarily long time, I must assume it's not longer applicable or otherwise not interesting to pursue.

If I'm wrong, please open a fresh PR against master.

@krakjoe krakjoe closed this Aug 31, 2025
@bukka
Copy link
Member

bukka commented Sep 4, 2025

It might be good to create an issue for this.

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.

4 participants