Skip to content

fix: ensure env is not in an invalid state on shutdown#1442

Merged
dunglas merged 3 commits intomainfrom
fix/invalid-env-on-shutdown
Mar 19, 2025
Merged

fix: ensure env is not in an invalid state on shutdown#1442
dunglas merged 3 commits intomainfrom
fix/invalid-env-on-shutdown

Conversation

@AlliBalliBaba
Copy link
Copy Markdown
Contributor

Fixes #1441

The issue is:
After releasing superglobals that have jit, they remain in an 'invalid state' as long as they are not reloaded ($_SERVER, $_ENV, $_REQUEST). Since $_ENV is not reloaded in worker mode, accessing the global directly will lead to a segfault.

Extensions like xdebug directly access the $_ENV global on shutdown.

This PR sets $_ENV to an empty array on worker script shutdown to fix the segfault. Ideally, $_ENV would not be released between requests, but I have not yet found a way to do so without causing a memory leak.

@dunglas dunglas merged commit 432824e into main Mar 19, 2025
50 of 56 checks passed
@dunglas dunglas deleted the fix/invalid-env-on-shutdown branch March 19, 2025 12:22
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.

Exit 139 (segfault) on octane:reload with xdebug.mode=debug

2 participants