Skip to content

[session] Clear in_save_handler recursion guard on bailout (GH-15529) - #296

Open
iliaal wants to merge 1 commit into
PHP-8.4from
fix/pux-sticky-flag-84
Open

[session] Clear in_save_handler recursion guard on bailout (GH-15529)#296
iliaal wants to merge 1 commit into
PHP-8.4from
fix/pux-sticky-flag-84

Conversation

@iliaal

@iliaal iliaal commented Aug 24, 2026

Copy link
Copy Markdown
Owner

ps_call_handler() set PS(in_save_handler) around call_user_function() with no protection against zend_bailout() raised inside a userland save handler callback, so a fatal error (for example running out of memory in write()) left the flag sticky and the shutdown flush then emitted a false "Cannot call session save handler in a recursive manner" warning and skipped the pending handler calls, losing the session data. The invocation is now wrapped in zend_try/zend_catch that clears the flag and falls through to argv cleanup before re-bailing out; since every userland handler entry point funnels through ps_call_handler() this single guard covers open/read/write/destroy/gc/create_sid/validate_sid/update_timestamp alike. The two bug60634 tests that encoded the old sticky-flag warning at request shutdown were updated to expect the now-working close handler instead.

ps_call_handler() set PS(in_save_handler) around call_user_function()
with no protection against zend_bailout() from inside a userland save
handler callback; a bailout in open/read/write/close/etc. left the flag
sticky so the shutdown flush falsely reported "Cannot call session save
handler in a recursive manner" and skipped the pending handler calls.
Wrap the invocation in zend_try/zend_catch that clears the flag and
falls through to argv cleanup before re-bailing out. Sibling audit: all
userland handler entry points funnel through ps_call_handler(), so this
single guard covers every path; PS_OPEN_FUNC()/PS_CLOSE_FUNC() already
carry outer try/catch for their own retval/status cleanup and remain as
is. bug60634_error_3.phpt and bug60634_error_4.phpt expected the old
sticky-flag warning at request shutdown and are updated to expect the
now-working close handler instead.
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