Skip to content

Fix GH-25360: ZipArchive assertion when error handler throws at shutdown - #25361

Open
lazerg wants to merge 2 commits into
php:PHP-8.6from
lazerg:fix/gh-25360
Open

lazerg wants to merge 2 commits into
php:PHP-8.6from
lazerg:fix/gh-25360

Conversation

@lazerg

@lazerg lazerg commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

When zip_close() fails in the object destructor at shutdown, the "Cannot destroy the zip context" warning goes to the user error handler. If that handler throws, there is no frame to catch the exception, so it bails out in the middle of php_zip_archive_release(). The refcount is already 0 but the archive is never freed and intern->archive is never cleared, so free_storage closes it again and hits the assertion. The warning now runs inside zend_try and sets bailout_callback like the progress/cancel callbacks do, so cleanup finishes and the destructor bails out afterwards.

The close warning in php_zipobj_close() gets the same guard. It is reached when the destructor never ran (e.g. after a memory limit fatal), and bailing out there leaked the libzip handle.

Fixes GH-25360

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.

1 participant