Skip to content

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

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

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

Comment thread ext/zip/php_zip.c Resolved

@LamentXU123 LamentXU123 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.

/cc @devnexen

LamentXU123 added a commit that referenced this pull request Nov 26, 2026
* PHP-8.6:
  Fix GH-25360: ZipArchive assertion when error handler throws at shutdown (#25361)
arnaud-lb added a commit to hohphu8/php-src that referenced this pull request Nov 26, 2026
* PHP-8.6:
  Fix stale string metadata in sodium_add() and sodium_increment() (php#25775)
  Sync `session.upload_progress.enabled` default in `php.ini-{development,production}` (php#25743)
  ext/pgsql: fix pg_fetch_object() JIT crash when constructor keeps $this
  Fix hash() and hash_file() hanging on invalid xxh3/xxh128 options (php#25777)
  Fix phar_set_inode() using the zend_string header instead of the filename (php#25768)
  Fix phpGH-25360: ZipArchive assertion when error handler throws at shutdown (php#25361)
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.

3 participants