Skip to content

Commit ed3811e

Browse files
committed
Revert "Increase serialize_lock while decoding session"
This reverts commit b8ef7c3. See bug #79031. The semantics of serialize locking aren't quite correct right now, and the use of the lock in this particular place makes us hit the issue in a common case. I'm reverting this commit for PHP 7.4 and will try to fix this properly for PHP 8, as I believe it will require ABI breakage.
1 parent 935a61d commit ed3811e

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

ext/session/session.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,18 +244,11 @@ static zend_string *php_session_encode(void) /* {{{ */
244244

245245
static int php_session_decode(zend_string *data) /* {{{ */
246246
{
247-
int res;
248247
if (!PS(serializer)) {
249248
php_error_docref(NULL, E_WARNING, "Unknown session.serialize_handler. Failed to decode session object");
250249
return FAILURE;
251250
}
252-
/* Make sure that any uses of unserialize() during session decoding do not share
253-
* state with any unserialize() that is already in progress (e.g. because we are
254-
* currently inside Serializable::unserialize(). */
255-
BG(serialize_lock)++;
256-
res = PS(serializer)->decode(ZSTR_VAL(data), ZSTR_LEN(data));
257-
BG(serialize_lock)--;
258-
if (res == FAILURE) {
251+
if (PS(serializer)->decode(ZSTR_VAL(data), ZSTR_LEN(data)) == FAILURE) {
259252
php_session_destroy();
260253
php_session_track_init();
261254
php_error_docref(NULL, E_WARNING, "Failed to decode session object. Session has been destroyed");

ext/standard/tests/serialize/bug70219_1.phpt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class obj implements Serializable {
1818
}
1919
function unserialize($data) {
2020
session_decode($data);
21-
return null;
2221
}
2322
}
2423

@@ -34,18 +33,20 @@ for ($i = 0; $i < 5; $i++) {
3433
var_dump($data);
3534
var_dump($_SESSION);
3635
?>
37-
--EXPECT--
36+
--EXPECTF--
3837
array(2) {
3938
[0]=>
40-
object(obj)#1 (1) {
39+
object(obj)#%d (1) {
4140
["data"]=>
4241
NULL
4342
}
4443
[1]=>
45-
object(obj)#2 (1) {
44+
object(obj)#%d (1) {
4645
["data"]=>
4746
NULL
4847
}
4948
}
50-
array(0) {
49+
object(obj)#1 (1) {
50+
["data"]=>
51+
NULL
5152
}

0 commit comments

Comments
 (0)