[session] Clear in_save_handler recursion guard on bailout (GH-15529) - #296
Open
iliaal wants to merge 1 commit into
Open
[session] Clear in_save_handler recursion guard on bailout (GH-15529)#296iliaal wants to merge 1 commit into
iliaal wants to merge 1 commit into
Conversation
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.
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.
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.