Skip to content

Fix GH-25772: pg_fetch_object() crashes with JIT when the constructor keeps a reference and the result is discarded - #25773

Closed
thunderer wants to merge 1 commit into
php:PHP-8.4from
thunderer:fix/pg-fetch-object-refcount
Closed

thunderer wants to merge 1 commit into
php:PHP-8.4from
thunderer:fix/pg-fetch-object-refcount

Conversation

@thunderer

Copy link
Copy Markdown
Contributor

Fixes GH-25772.

pg_fetch_object() calls the constructor on the object it returns, and the constructor can keep a reference to $this. The stub still declared @refcount 1, so function JIT and tracing JIT destroyed the object when the result was discarded, while that reference still used it.

This drops the annotation and regenerates the arginfo and optimizer info, as 684612c did for pg_fetch_all_columns(). The test fails without the change.

The merge into PHP-8.5 and PHP-8.6 conflicts only in the stub hash line of ext/pgsql/pgsql_arginfo.h; build/gen_stub.php regenerates it.

…tor keeps a reference and the result is discarded

pg_fetch_object() calls the constructor on the returned object, and the
constructor can keep a reference to $this. The stub still declared
@refcount 1, which lets function JIT and tracing JIT destroy the object when
the result is discarded while that reference still uses it. Drop the
annotation.
@devnexen devnexen closed this in c726574 Nov 26, 2026
@thunderer
thunderer deleted the fix/pg-fetch-object-refcount branch November 26, 2026 12:30
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.

2 participants