• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

extphprs / ext-php-rs / 25678863190
66%

Build:
DEFAULT BRANCH: master
Ran 11 May 2026 03:15PM UTC
Jobs 1
Files 96
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

11 May 2026 03:12PM UTC coverage: 66.23% (-0.01%) from 66.241%
25678863190

push

github

web-flow
fix: leak one refcount in ZBox<ZendClassObject<T>>::set_zval (#735)

* fix: leak one refcount in ZBox<ZendClassObject<T>>::set_zval

ZBox::into_raw transfers ownership without touching the
refcount, so the box's single ref carries into set_object.
set_object then calls inc_count, bumping the count to 2.
The zval drops one ref on destruction; the object never
reaches zero and leaks.

On a PHP debug build the leak cascades into an assertion in
_zend_hash_str_add_or_update_i at module shutdown: leaked
instances keep shared class storage (used by classes with
#[php(prop)] fields) alive past its expected lifetime, and
property cleanup hits a frozen hashtable without the
HASH_FLAG_ALLOW_COW_VIOLATION bit.

Apply the same fix already present on the sibling impl
ZBox<ZendObject>::set_zval in object.rs: call dec_count
before into_raw so the net post-insertion count stays at 1.
The matching impl for RegisteredEnum + RegisteredClass in
enum_.rs had the same bug and is fixed alongside.

* test: regression coverage for ZendClassObject<T> set_zval refcount leak

Adds an integration test that exercises the exact buggy code path
fixed in the previous commit: a class extending \Exception with a
#[php(prop)] field, constructed via ZendClassObject::new(...)
.into_zval(...) and thrown via PhpException::with_object. The
caught exception's refcount is read inside the catch block via
debug_zval_dump; with the fix the only holder is the catch-bound
variable, so the dump reports refcount 2. Without the fix the
buggy set_zval keeps an extra ref and the dump reports 3.

Refcount via debug_zval_dump was chosen over a memory-growth
measurement so the same assertion fires on release and debug PHP
builds. memory_get_usage / gc_collect_cycles interact poorly with
a separate latent refcount bug in the IntoZval impl for
&mut ZendClassObject<T> (out of scope here): on debug builds GC
tries to add to a shared HT and trips
_zend_hash_str_add_or_update_i.

Verified against PHP 8.4.20 NTS ... (continued)

0 of 4 new or added lines in 2 files covered. (0.0%)

8653 of 13065 relevant lines covered (66.23%)

33.26 hits per line

Uncovered Changes

Lines Coverage ∆ File
2
41.18
-0.82% src/enum_.rs
2
0.0
0.0% src/types/class_object.rs
Jobs
ID Job ID Ran Files Coverage
1 25678863190.1 11 May 2026 03:15PM UTC 96
66.23
GitHub Action Run
Source Files on build 25678863190
  • Tree
  • List 96
  • Changed 2
  • Source Changed 2
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #25678863190
  • 7a2ffc7d on github
  • Prev Build on master (#25677436323)
  • Next Build on master (#25680438706)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc