Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash in PDO_ODBC statement dtor #17586

Merged
merged 1 commit into from
Jan 27, 2025

Conversation

NattyNarwhal
Copy link
Member

Port of 2ae897f to PDO_ODBC. (GH-17585 is this, but for master instead of 8.3, targeting against correct version)

@nielsdos
Copy link
Member

(For reference, #17567 is the function I'll introduce in master, I'll rebase after this is merged)

// TODO: Factor this out; pg/mysql/firebird do the same thing
bool server_obj_usable = !Z_ISUNDEF(stmt->database_object_handle)
&& IS_OBJ_VALID(EG(objects_store).object_buckets[Z_OBJ_HANDLE(stmt->database_object_handle)])
&& !(OBJ_FLAGS(Z_OBJ(stmt->database_object_handle)) & IS_OBJ_FREE_CALLED);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is super ugly. Wouldn't it be cleaner if the dbh would keep a list of stmts, so it could null stmt->H when being destroyed?

Copy link
Member

@nielsdos nielsdos Jan 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's more convoluted and consumes more memory, and the dbh destruction (at the driver site) already destroys the driver statements too. Imo, this is good enough especially when hidden behind a function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough!

Could it make sense to move that into Zend/ to have a generic function? I think that not only PDO is affected by this; likely also other DB extensions, and even others (enchant broker/dictinonary comes to mind)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enchant shouldn't be affected as it does not create strong cycles and even does its own refcounting of the broker IIRC.
Other DB extension: could be affected indeed.

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, hopefully this fixes nightly

@NattyNarwhal NattyNarwhal marked this pull request as ready for review January 26, 2025 21:21
@NattyNarwhal NattyNarwhal merged commit 556def7 into php:PHP-8.3 Jan 27, 2025
9 checks passed
NattyNarwhal added a commit that referenced this pull request Jan 27, 2025
* PHP-8.3:
  Fix crash in PDO_ODBC statement dtor (#17586)
NattyNarwhal added a commit that referenced this pull request Jan 27, 2025
* PHP-8.4:
  Fix crash in PDO_ODBC statement dtor (#17586)
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.

4 participants