Skip to content

fix: concurrent env access #1409

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

Merged
merged 13 commits into from
Mar 1, 2025
Merged

fix: concurrent env access #1409

merged 13 commits into from
Mar 1, 2025

Conversation

AlliBalliBaba
Copy link
Contributor

@AlliBalliBaba AlliBalliBaba commented Feb 25, 2025

This is an attempt at fixing #1395 #1061 #1353

The idea is basically to sandbox the environment on a per-thread basis and to not flush $_ENV values in worker mode.

This still allows putenv to affect the actual environment (in case of forking). It does not fully resolve all environment races in ZTS, but will resolve all races for $_ENV, $_SERVER and through getenv().

@AlliBalliBaba
Copy link
Contributor Author

AlliBalliBaba commented Feb 27, 2025

To reiterate , this fixes:

  • $_ENV randomly getting reloaded in worker mode on script compilation
  • threads affecting each other's $_ENV and $_SERVER (while still allowing putenv to affect the actual environment)

Important to mention:

@AlliBalliBaba AlliBalliBaba marked this pull request as ready for review February 27, 2025 21:24
Copy link
Member

@dunglas dunglas left a comment

Choose a reason for hiding this comment

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

LGTM! Very good work.

Copy link
Member

@withinboredom withinboredom left a comment

Choose a reason for hiding this comment

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

LGTM. It might also be worth updating the documentation on worker mode in this PR to inform users how worker mode affects the environment (or doesn't).

@dunglas dunglas merged commit c57f741 into main Mar 1, 2025
55 checks passed
@dunglas dunglas deleted the fix/concurrent-env branch March 1, 2025 13:45
@dunglas
Copy link
Member

dunglas commented Mar 1, 2025

Thank you! Great as usual.

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.

3 participants