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)
arnaud-lb added a commit to arnaud-lb/php-src that referenced this pull request Nov 30, 2026
* PHP-8.6: (58 commits)
  Fix phpGH-24701: Use-after-free on typed trait constants during opcache preload (php#24710)
  ext/dom: Guard namespace prefix lookup for non-element nodes
  ext/pdo_sqlite: crash when a collation callback closes the statement cursor
  Admit NTS requests to OPcache SHM only in RINIT (php#25509)
  ext/pgsql: pg_meta_data() numeric column names not integer keys with opcache
  [skip ci] Add NEWS entry for php#25674
  ext/bz2: Fix NULL dereference when compress.bzip2:// open fails in write mode
  ext/dom: Reject DTD declaration nodes in adoptNode()
  Fix iconv_mime_encode() overflowing on a negative line-length (php#25485)
  ext/pgsql: pg_get_notify() result is never === false with opcache enabled
  ext/zlib: fix gzwrite() not reporting write errors
  Fix phpGH-25788: clone() with properties corrupts memory with JIT when __clone() keeps a reference and the result is discarded (php#25787)
  Fix phpGH-25779: mysqli_fetch_object() crashes with JIT when the constructor keeps a reference and the result is discarded (php#25784)
  Fix partial application treating methods named assert() as the global assert() (php#25771)
  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