Skip to content

Fix session memory leak on failed user save handler close#22440

Open
abolfazl-moeini wants to merge 1 commit into
php:masterfrom
abolfazl-moeini:fix/session-abort-leak
Open

Fix session memory leak on failed user save handler close#22440
abolfazl-moeini wants to merge 1 commit into
php:masterfrom
abolfazl-moeini:fix/session-abort-leak

Conversation

@abolfazl-moeini

Copy link
Copy Markdown

Fixes the memory leak reported in #21200 after #21200 was reverted in 3073948.

The reverted patch saved/restored EG(exception) around s_close() in
php_session_abort(). That changed exception behaviour and did not fix
leaks when a SessionHandler subclass close() returned false without
calling parent::close().

Changes:

  • php_session_abort() tears down session state like php_rshutdown_session_globals()
  • ps_close_user() closes the default save handler when mod_data is still set

Tests (debug build leak detection):

  • ext/session/tests/session_abort_validateid_leak.phpt
  • ext/session/tests/session_close_false_leak.phpt

0acde11 was reverted in 3073948. That patch swapped EG(exception)
around s_close() in php_session_abort() and did not cover close()
returning false without parent::close().

php_session_abort() now tears down session state the same way
php_rshutdown_session_globals() does. ps_close_user() closes the
default save handler when mod_data is still allocated after the
userland close callback.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant