Skip to content

Fix GH-24350: Stale external tz database read after module restart - #24354

Open
lazerg wants to merge 2 commits into
php:PHP-8.4from
lazerg:fix/gh-24350-date-stale-tzdb
Open

lazerg wants to merge 2 commits into
php:PHP-8.4from
lazerg:fix/gh-24350-date-stale-tzdb

Conversation

@lazerg

@lazerg lazerg commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

PHP_MINIT_FUNCTION(date) registered its INI entries before resetting php_date_global_timezone_db. Registering date.timezone runs OnUpdate_date_timezone(), which checks the value against DATE_TIMEZONEDB. On an in-process engine restart (Apache graceful reload, FrankenPHP worker restart), that pointer still points into the PECL timezonedb .so that the previous shutdown unloaded, so startup reads unmapped memory and crashes in seek_to_tz_position(). The reset now happens before REGISTER_INI_ENTRIES().

I checked it with a small embed host on macOS: it loads timezonedb as a shared extension, calls php_embed_init()/php_embed_shutdown() twice, and maps a PROT_NONE region over the address range the unloaded .so used. Before the fix, the second startup crashes in seek_to_tz_position(). After the fix, it starts normally and still uses the external database. There is no test, because run-tests cannot restart the engine inside one process.

Fixes GH-24350

@lazerg

lazerg commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

The FreeBSD job fails because the FreeBSD 13 package mirror returns 404. It fails the same way on other PRs today, so my change does not cause it.

@ndossche ndossche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks

@lazerg

lazerg commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

The macOS job fails on ext/zip/tests/oo_torrentzip.phpt. The same test fails on other PRs today (for example #24365 and #24367), so my change does not cause it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ext/date: MINIT reads a stale external tz database after an in-process module restart

3 participants