[php-src] Issue #10599: Apache crash on Windows when using a self-referencing anonymous function inside a class with an active mysqli connection

From: Date: Wed, 15 Feb 2023 13:07:11 +0000
Subject: [php-src] Issue #10599: Apache crash on Windows when using a self-referencing anonymous function inside a class with an active mysqli connection
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243733@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/10599 Author: DaGaMx ### Description The following code: ```php <?php $x = new X(); $x->y(); class X { public function __construct() { $this->link = @new mysqli(); @$this->link->connect('.', 'root', 'password', 'instance', null, '\\\\.\\pipe\\pipeName); } public function y() { $parseConnection = null; $parseConnection = function() use (&$parseConnection) { }; } } ``` Resulted in this output: ``` The Apache service crashes after accessing this page multiple times (reload the page 2 to 5 times). In the Windows Event viewer you can find this message (sorry for the German text, but the OS is in German): -------------------------------------------------------------- Name der fehlerhaften Anwendung: httpd.exe, Version: 21.3.0.49152, Zeitstempel: 0x61646032 Name des fehlerhaften Moduls: php8ts.dll, Version: 8.1.14.0, Zeitstempel: 0x63b57733 Ausnahmecode: 0xc0000005 Fehleroffset: 0x000000000005cc55 ID des fehlerhaften Prozesses: 0xdfc Startzeit der fehlerhaften Anwendung: 0x01d9413adafb9578 Pfad der fehlerhaften Anwendung: C:\apache\bin\httpd.exe Pfad des fehlerhaften Moduls: C:\apache\php-8.1.14-Win32-vs16-x64\php8ts.dll Berichtskennung: b79274d7-45ed-48f8-a592-478bcbe8df41 Vollständiger Name des fehlerhaften Pakets: Anwendungs-ID, die relativ zum fehlerhaften Paket ist: ``` But I expected this output instead: ``` It should just work, without any process crashes. In PHP 7.3 this code works fine. Starting with PHP 7.4 I got the crash. ``` I've tested much to find this bug. It only appears if you have a mysqli connection inside of the class instance. Also you need to use a anonymous function with a referenced use of the variable where you assign the anonymous function. As a workaround for me I will get rid of this anonymous function now. But however it should not be possible to crash the executing process like this. ### PHP Version PHP 8.1.14 (the bug exists since 7.4, in 7.3 there is no crash) ### Operating System Windows

« previous php.bugs (#243733) next »