Skip to content

ext/sqlite3: hold the callback guard until the callback's values are gone - #311

Closed
iliaal wants to merge 1 commit into
PHP-8.4from
fix/gh-23650-in-callback-cleanup
Closed

iliaal wants to merge 1 commit into
PHP-8.4from
fix/gh-23650-in-callback-cleanup

Conversation

@iliaal

@iliaal iliaal commented Sep 17, 2026

Copy link
Copy Markdown
Owner

phpGH-23650 made SQLite3::close() throw while a callback is running, but each callback wrapper dropped its re-entry counter as soon as the userland call returned, before the return value and arguments were converted and released. A destructor firing during that release still runs with sqlite3 on the stack, so it could close the database and finalize the statement being stepped, reaching the crash phpGH-23650 was meant to stop. Found while auditing the sibling in php#23728.

…gone

phpGH-23650 made SQLite3::close() throw while a callback is running by counting
re-entry into the four callback kinds, but each wrapper dropped the counter
as soon as the userland call returned, before converting the return value and
releasing it and the arguments. A destructor firing during that release still
runs with sqlite3 on the stack, so it could close the database and finalize
the statement being stepped, which is the crash phpGH-23650 was meant to stop.
Drop the counter after the values are released instead.
@iliaal

iliaal commented Sep 17, 2026

Copy link
Copy Markdown
Owner Author

Submitted upstream as php#23734.

@iliaal iliaal closed this Sep 17, 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