Skip to content

ext/sqlite3: reject close() from inside a callback - #258

Open
iliaal wants to merge 1 commit into
PHP-8.4from
fix/sqlite3-close-callback-84
Open

ext/sqlite3: reject close() from inside a callback#258
iliaal wants to merge 1 commit into
PHP-8.4from
fix/sqlite3-close-callback-84

Conversation

@iliaal

@iliaal iliaal commented Aug 24, 2026

Copy link
Copy Markdown
Owner

SQLite3::close() called from within a userland function, aggregate, collation or authorizer callback freed the registered statements and functions while sqlite3 was still executing the callback, leaving the active statement corrupted and crashing the request (segfault reproduced on 8.4, 8.5 and master).

Track callback re-entry with a per-database counter shared by all four callback kinds and throw an Error from close() while it is non-zero. The database stays usable and closes normally once the query completes. The regression test segfaults pre-patch and passes post-patch.

SQLite3::close() called from within a userland function, aggregate,
collation or authorizer callback freed the registered statements and
functions while sqlite3 was still executing, corrupting the active
statement and crashing the request. Track callback re-entry with a
per-database counter shared by all four callback kinds and throw an
Error from close() while it is non-zero; the database stays usable and
can be closed after the query completes.
@iliaal iliaal closed this Aug 24, 2026
@iliaal iliaal reopened this Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant