[php-src] PR #16748: Fix GH-16727: Opcache bad signal 139 crash in ZTS bookworm (frankenphp)

From: Date: Sun, 10 Nov 2024 22:28:49 +0000
Subject: [php-src] PR #16748: Fix GH-16727: Opcache bad signal 139 crash in ZTS bookworm (frankenphp)
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-29588@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/16748 Author: nielsdos Reproducer: https://github.com/php/php-src/issues/16727#issuecomment-2466256317 The root cause is a data race between two different threads: 1) We allocate a lower cased name for an anonymous class here: https://github.com/php/php-src/blob/f97353f228e21dcc2db24d7edf08c1cb3678b0fd/Zend/zend_compile.c#L8109 2) This gets looked up as an interned string here: https://github.com/php/php-src/blob/f97353f228e21dcc2db24d7edf08c1cb3678b0fd/Zend/zend_compile.c#L8112 Assuming that there are uppercase symbols in the string and therefore lcname != name and that lcname is not yet in the interned string table, the pointer value of lcname won't change. 3) Here we add the string into the interned string table: https://github.com/php/php-src/blob/f97353f228e21dcc2db24d7edf08c1cb3678b0fd/Zend/zend_compile.c#L8223 However, in the meantime another thread could've added the string into the interned string table. This means that the following code will run, indirectly called via the LITERAL_STR macro, freeing lcname: https://github.com/php/php-src/blob/62e53e6f4965f37d379a3fd21f65a4210c5c86b5/ext/opcache/ZendAccelerator.c#L572-L575 4) In the reproducer we then access the freed lcname string here: https://github.com/php/php-src/blob/f97353f228e21dcc2db24d7edf08c1cb3678b0fd/Zend/zend_compile.c#L8229 This is solved in my patch by retrieving the interned string pointer and putting it in lcname.

« previous php.git-pulls (#29588) next »