Repository navigation
Conversation
Every PDO object attached to a persistent connection shares one pdo_dbh_t, and dbh_get_gc() reported the driver's GC data once per object. pdo_sqlite holds each user function, aggregate and collation callback once, so with two or more objects the collector subtracted more references than exist and freed live closures, crashing or returning wrong results. Report driver GC data only while a single object owns the handle, the same refcount check the rollback guard uses since phpGH-23962. While the connection is shared, cycles through those callbacks are left to request shutdown, as they already are with GC disabled. No other bundled driver implements get_gc.
Owner
Author
|
Promoted to php#24529. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every PDO object attached to a persistent connection shares one
pdo_dbh_t, anddbh_get_gc()reported the driver's GC data once per object. pdo_sqlite holds each user function, aggregate and collation callback once, so twoPdo\Sqlite::connect()calls withATTR_PERSISTENTon the same DSN, each registering a method as a UDF, make the collector count two references for one and free closures still in use: the next query fails or crashes, and debug builds assert inzend_gc_delref. This has been the case since driver GC data was added in 8.1.Driver GC data is now reported only while a single object owns the handle, the check the rollback guard got for phpGH-23962. While the connection is shared, cycles through those callbacks wait for request shutdown, which is already what happens with GC disabled; that is also why the test unsets the handles at the end. Functions, aggregates and collations go through the same call and were each checked, and no other bundled driver implements
get_gc.Found while testing php#24041; verified on a PHP-8.4 debug NTS build with the test red before and green after, plus valgrind memcheck on the patched build.