[php-src] PR #20824: Fix GH-20727: User code can run after module request shutdown via the output layer
| From: | ndossche | Date: | Sat, 03 Jan 2026 15:50:36 +0000 |
| Subject: | [php-src] PR #20824: Fix GH-20727: User code can run after module request shutdown via the output layer | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-34441@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/20824
Author: ndossche
If user code runs after modules executed RSHUTDOWN, it can be dangerous because user code can rely
on module globals that have already been invalidated.
We should not run user code after RSHUTDOWN.
This is shown by the test by using putenv(). The original report demonstrated a silent failure via
mbstring. There are more test cases possible but this is by far the simplest.
An alternative solution would be to try to separate the user code running via php_header() from the
output layer shutdown, to make sure user code runs earlier. However, that becomes an ugly complex
solution. This PR's solution keeps things simple but this can be a BC break if extensions
produce output in their RSHUTDOWN handler (However, that may have been unsafe in the first place).