Skip to content

[session] Close save handler before re-initializing an active session - #261

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

[session] Close save handler before re-initializing an active session#261
iliaal wants to merge 1 commit into
PHP-8.4from
fix/session-reset-close-84

Conversation

@iliaal

@iliaal iliaal commented Aug 24, 2026

Copy link
Copy Markdown
Owner

php_session_initialize() could be entered while a session was already active, e.g. through session_reset() or the rfc1867 upload-progress callbacks, causing the save handler open() method to be invoked a second time with no intervening close(), which leaks the first handler instance and breaks userland handlers that track state per open/close pair. The initialize path now aborts an already-active session, which closes the handler via php_session_abort(), before reopening it. Sibling audit: php_session_start() already returns early while a session is active; the strict-mode create_sid fallback branch relies on the existing php_session_reset_id() failure guard, which already closes the handler; and a new regression test asserts the expected open/read/close/open/read callback sequence.

php_session_initialize() now aborts an already-active session (closing
the save handler) before reopening it, so session_reset() no longer
calls open() twice with no close(). Sibling audit: php_session_start()
returns early while a session is active; the strict-mode create_sid
fallback leaves the close to the existing php_session_reset_id()
failure guard, which already calls php_session_abort(); the rfc1867
update/cleanup callbacks are covered by the same new guard.
@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