View Issue Details

IDProjectCategoryView StatusLast Update
0001772XdebugUncategorizedpublic2020-04-04 11:08
Reporterbag64Assigned Toderick 
Status closedResolutionfixed 
Product Version2.9.4 
Target Version2.9.5Fixed in Version2.9.5 
Summary0001772: Crash with exception thrown inside a destructor
DescriptionPHP crashes when XDebug is enabled.
And this only happens when code is wrapped in a PHPunit test for some reason, here's a snipet of the code:

class X
    public function __destruct(){
        throw new \Exception('eee');

class InstanceTest extends \PHPUnit\Framework\TestCase

    // This part is important, and is what's causing the crash:
    private ?X $x = null;
    function get_instance():X{return $this->x = $this->get_new_instance();}
    function get_new_instance():X{return new X();}

    public function test_instance()

Result = Process finished with exit code -1073741819 (0xC0000005)
Steps To Reproducejust run phpunit with instanceTest.php (file attached)
Additional InformationTested on both: (same error)


PHPUnit version: 8.4.3
TagsNo tags attached.
Operating SystemWindows 7
PHP Version7.4.0-7.4.4



2020-04-02 15:48


InstanceTest.php (514 bytes)
php_crash.png (39,743 bytes)
php_crash.png (39,743 bytes)


2020-04-02 17:47

reporter (2,530,352 bytes)


2020-04-02 17:47

reporter   ~0005362

I attached a complete workspace example (nothing to setup)
Just double click "crash_test_windows.bat" on Windows and see the crash in action.

I don't know about linux, but "" should also work in theory.

I hope this could help.


2020-04-03 00:03

administrator   ~0005363

I can't reproduce this (on Linux). I had to do "rm -rf vendor" and "composer install" to make the code run, but I am not getting a crash (or a valgrind memory checking warning). Which settings do you have enabled for PHP/Xdebug? Can you check the html_errors, display_errors, and error_reporting settings, as well as the phpinfo section of Xdebug, and attach these as a file? You can get these by running "php -i" (but please leave out the things I didn't ask for).


2020-04-03 10:04


derick_phperrorerror.log (867 bytes)
derick_phpinfo.log (3,111 bytes)
derick_phpxdebug.ini (1,039 bytes)


2020-04-03 10:10

reporter   ~0005365

Would you like me to setup and attach a Standalone test environement (that includes php binaries) and upload it here for you to test and execute ?
In the meanwhile I will try to setup this and test it in linux and report back if I find anything.


2020-04-03 10:18

administrator   ~0005366

Happy to test a specific set-up that you can make and share. I'm not quite sure what that would include though? I don't think this bug system wants really large files :-)


2020-04-03 11:32


xdebug_crash.rar (2,263,738 bytes)


2020-04-03 11:32

reporter   ~0005367

Hi Derick. Yes I'm aware of the 5MB limit :( This is why I made this batch script for you,
and it is (x86) 32bits compatible so you can run in any Win7+ Virtual Machine painlessly.

You need to download:
And extract it in "./php" folder, WITHOUT overriding the exisiting files.

Also, you need to extract this in "C:\xdebug_crash" for it to work properly.

Once you setup the workspace, you will notice a curios phenomenon:
If you double click "crash_test.bat" it will crash, but if you edit "CrashTest.php" and replace

public function test_crash()


public function test_crash()
        $this->get_new_instance(); // <-- notice "_new_"

It will NOT crash ! weird huh..
Let me know if the workspace works for you and if you were able to see it crash.


2020-04-03 11:41

reporter   ~0005368

for sake of clarity here's the steps again:

1) Download "xdebug_crash.rar" above and extract content in "c:\xdebug_crash\"
2) Download "" above and extract content in "c:\xdebug_crash\php\"
3) Run "crash_test.bat" (Expecting crash)
4) Edit "CrashTest.php" and replace "get_instance" by "get_new_instance()" as explained above
5) Run "crash_test.bat" (Expecting NO crash this time)


2020-04-03 12:14

administrator   ~0005370

I don't have Windows at all, so that makes testing on it hard...


2020-04-03 12:31

reporter   ~0005371

Oh. I could setup a temporary VNC for you if it could help.
Either VNC, RDP, TeamViewer or whatever would work and help you, would that be ok ?


2020-04-03 14:15

administrator   ~0005372


thanks for setting that up. I've managed to find where the problem is, and I can now reproduce this locally on Linux. I also have a fix already, but I would like to come up with a small reproducible case before I commit this.



2020-04-03 14:27

reporter   ~0005373

Happy to hear that :-) And sorry for making you go through that VS registration pain.
I'll make sure it's up to date next time
Thank you !


2020-04-04 10:01

administrator   ~0005375

This is now fixed in Git. Once AppVeyor finishes building the binaries, you can find your right configuration at . Click on the configuration, and then the artifacts tab. I did not manage to make a small reproducible case unfortunately.


2020-04-04 11:08

reporter   ~0005376

Great ! Problem seems to be solved, no more crashes :)

Issue History

Date Modified Username Field Change
2020-04-02 15:48 bag64 New Issue
2020-04-02 15:48 bag64 File Added: InstanceTest.php
2020-04-02 15:48 bag64 File Added: php_crash.png
2020-04-02 17:47 bag64 File Added:
2020-04-02 17:47 bag64 Note Added: 0005362
2020-04-03 00:03 derick Assigned To => derick
2020-04-03 00:03 derick Status new => feedback
2020-04-03 00:03 derick Note Added: 0005363
2020-04-03 10:04 bag64 File Added: derick_phperrorerror.log
2020-04-03 10:04 bag64 File Added: derick_phpinfo.log
2020-04-03 10:04 bag64 File Added: derick_phpxdebug.ini
2020-04-03 10:10 bag64 Note Added: 0005365
2020-04-03 10:10 bag64 Status feedback => assigned
2020-04-03 10:18 derick Note Added: 0005366
2020-04-03 11:32 bag64 File Added: xdebug_crash.rar
2020-04-03 11:32 bag64 Note Added: 0005367
2020-04-03 11:41 bag64 Note Added: 0005368
2020-04-03 12:14 derick Note Added: 0005370
2020-04-03 12:31 bag64 Note Added: 0005371
2020-04-03 14:15 derick Note Added: 0005372
2020-04-03 14:27 bag64 Note Added: 0005373
2020-04-04 09:34 derick Target Version => 2.9.5
2020-04-04 09:34 derick Summary PHP/XDebug crash whenever Exception thrown inside a destructor, in PHPUnit => Crash with exception thrown inside a destructor
2020-04-04 09:34 derick Description Updated View Revisions
2020-04-04 09:34 derick Additional Information Updated View Revisions
2020-04-04 10:01 derick Status assigned => closed
2020-04-04 10:01 derick Resolution open => fixed
2020-04-04 10:01 derick Fixed in Version => 2.9.5
2020-04-04 10:01 derick Note Added: 0005375
2020-04-04 11:08 bag64 Note Added: 0005376