From 3073948885d95c42ab4ce97109edb2b8f4dc6ed4 Mon Sep 17 00:00:00 2001 From: ndossche <7771979+ndossche@users.noreply.github.com> Date: Tue, 10 Mar 2026 20:27:48 +0100 Subject: [PATCH] Revert "ext/session: Fix memory leak due to multiple exception happening during session abort" This reverts commit 0acde1194513ff69c491f3c1ebe103c3774dc7fd. The patch is incorrect as described in GH-21200 in the post-merge comments. --- NEWS | 4 --- ext/session/session.c | 11 +----- ...sessionhandler_validateid_return_type.phpt | 35 ------------------- .../session_set_save_handler_class_012.phpt | 2 -- 4 files changed, 1 insertion(+), 51 deletions(-) delete mode 100644 ext/session/tests/sessionhandler_validateid_return_type.phpt diff --git a/NEWS b/NEWS index 9f2b1ed85e2..5380688ce3d 100644 --- a/NEWS +++ b/NEWS @@ -13,10 +13,6 @@ PHP NEWS . Fixed preprocessor silently guarding PGSQL_SUPPRESS_TIMESTAMPS support due to a typo. (KentarouTakeda) -- Session: - . Fix memory leak due to multiple exception happening during session abort. - (arshidkv12) - - SNMP: . Fixed bug GH-21336 (SNMP::setSecurity() undefined behavior with NULL arguments). (David Carlier) diff --git a/ext/session/session.c b/ext/session/session.c index f8d963b4894..70e1673d87f 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -41,7 +41,6 @@ #include "ext/standard/url_scanner_ex.h" #include "ext/standard/info.h" #include "zend_smart_str.h" -#include "zend_exceptions.h" #include "ext/standard/url.h" #include "ext/standard/basic_functions.h" #include "ext/standard/head.h" @@ -1744,16 +1743,8 @@ PHPAPI php_session_status php_get_session_status(void) static zend_result php_session_abort(void) /* {{{ */ { if (PS(session_status) == php_session_active) { - if ((PS(mod_data) || PS(mod_user_implemented)) && PS(mod)->s_close) { - zend_object *old_exception = EG(exception); - EG(exception) = NULL; - + if (PS(mod_data) || PS(mod_user_implemented)) { PS(mod)->s_close(&PS(mod_data)); - if (!EG(exception)) { - EG(exception) = old_exception; - } else if (old_exception) { - zend_exception_set_previous(EG(exception), old_exception); - } } PS(session_status) = php_session_none; return SUCCESS; diff --git a/ext/session/tests/sessionhandler_validateid_return_type.phpt b/ext/session/tests/sessionhandler_validateid_return_type.phpt deleted file mode 100644 index a1006945882..00000000000 --- a/ext/session/tests/sessionhandler_validateid_return_type.phpt +++ /dev/null @@ -1,35 +0,0 @@ ---TEST-- -SessionHandler::validateId must return bool ---INI-- -session.use_strict_mode=1 ---EXTENSIONS-- -session ---SKIPIF-- - ---FILE-- -getMessage(), "\n"; -} - -session_write_close(); - -try { - session_start(); -} catch (Throwable $e) { - echo $e->getMessage(), "\n"; -} -?> ---EXPECTF-- -Session id must be a string diff --git a/ext/session/tests/user_session_module/session_set_save_handler_class_012.phpt b/ext/session/tests/user_session_module/session_set_save_handler_class_012.phpt index a532dff7f82..f96206efbb6 100644 --- a/ext/session/tests/user_session_module/session_set_save_handler_class_012.phpt +++ b/ext/session/tests/user_session_module/session_set_save_handler_class_012.phpt @@ -43,8 +43,6 @@ var_dump(session_id(), $oldHandler, ini_get('session.save_handler'), $handler->i --EXPECTF-- *** Testing session_set_save_handler() : incorrect arguments for existing handler open *** Open: - -Warning: SessionHandler::close(): Parent session handler is not open in %s on line %d SessionHandler::open() expects exactly 2 arguments, 0 given Warning: Undefined global variable $_SESSION in %s on line %d