View Issue Details

IDProjectCategoryView StatusLast Update
0002097XdebugUncategorizedpublic2022-12-07 12:22
Reporterravage Assigned Toderick  
PrioritynormalSeveritycrashReproducibilityalways
Status resolvedResolutionunable to reproduce 
Platform64-bitOSWindows 10 ProOS Version19043.1706
Product Version3.1.5 
Summary0002097: Xdebug crashes with exit code -1073740940 (0xC0000374) on Windows 10 Pro & PHP 7.3.x when Develop Mode is active
Description

Since version 3.1.2 and onward Xdebug crashes with "Process finished with exit code -1073741819 (0xC0000005)" on Windows 10 Pro using PHP 7.3.33 (also 7.3.5) in Develop mode is active when running a PHPUnit test suite on some of our CakePHP 3.x based applications.

Going back to Xdebug 3.1.1 solved the issue.

We tested these variations:

zend_extension="php_xdebug-3.0.3-7.3-vc15-x86_64.dll" -> OK
xdebug.mode=develop,debug,coverage

zend_extension="php_xdebug-3.1.1-7.3-vc15-x86_64.dll" -> OK
xdebug.mode=develop,debug,coverage

zend_extension="php_xdebug-3.1.2-7.3-vc15-x86_64.dll" -> FAIL
xdebug.mode=develop,debug,coverage

zend_extension="php_xdebug-3.1.3-7.3-vc15-x86_64.dll" -> FAIL
xdebug.mode=develop,debug,coverage

zend_extension="php_xdebug-3.1.4-7.3-vc15-x86_64.dll" -> FAIL
xdebug.mode=develop,debug,coverage

zend_extension="php_xdebug-3.1.5-7.3-vc15-x86_64.dll" -> FAIL
xdebug.mode=develop,debug,coverage

zend_extension="php_xdebug-3.1.5-7.3-vc15-x86_64.dll"
xdebug.mode=debug -> OK

zend_extension="php_xdebug-3.1.5-7.3-vc15-x86_64.dll"
xdebug.mode=coverage ->OK

zend_extension="php_xdebug-3.1.5-7.3-vc15-x86_64.dll"
xdebug.mode=develop -> FAIL

zend_extension="php_xdebug-3.1.5-7.3-vc15-x86_64.dll"
xdebug.mode=debug, coverage -> OK

zend_extension="php_xdebug-3.1.5-7.3-vc15-x86_64.dll"
xdebug.mode=debug, develop -> FAIL

zend_extension="php_xdebug-3.1.5-7.3-vc15-x86_64.dll"
xdebug.mode=develop, coverage -> FAIL

Steps To Reproduce

Haven't found a way to reproduce this without our private code base.

Additional Information

I remember CakePHP Chronos, which we also use, used to have issues with Xdebug. But this was a few years ago.

Tagscrash, develop, phpunit
Operating System
PHP Version7.3.30-7.3.39

Activities

derick

2022-06-09 09:02

administrator   ~0006329

Last edited: 2022-06-09 09:27

Hi,

I have had a look at the differences between 3.1.1 and 3.1.2 in the source code, but nothing specific jumped out that could hint at an extra cause for a segfault. I'm afraid I am going to need some more information.

  1. Preferably a backtrace, as is explained under "Generating backtrace, without compiler, on Windows" at https://bugs.php.net/bugs-generating-backtrace-win32.php — this provides a hint to me where the crash could occur. Installing the debug pack as mentioned earlier in that file, would be a great help too. Because your PHP version is no longer supported by the PHP project, you can find the php-debug-pack that you need in https://windows.php.net/downloads/releases/archives/.
  2. To narrow down where in your code this occurs, configure xdebug.mode=develop,trace and set xdebug.start_with_request=yes, and perhaps xdebug.output_dir=C:\Temp (or something more suitable), and then run the tests. This should create a (big) trace file in that directory, up to the point where it crashes. You might get lucky that the actual call is there, but otherwise it should be the next one.

You might also want to check whether opcache is enabled, and whether removing that changes anything.

cheers,
Derick

derick

2022-06-27 09:50

administrator   ~0006335

Sorry it took me some time to come back to this. I don't have the faintest what this could be, but I am making a reasonable guess that some sequence does make this happen. It does seem to happen when an exception is thrown, which fetches a backtrace :

php7ts!zend_= fetch_debug_backtrace+138 [c:\php-snap-build\php73\vc15\x64\php-7.3.3= 3-ts\zend\zend_builtin_functions.c @ 2489 + 5]php7ts!zend= _default_exception_new_ex+95 [c:\php-snap-build\php73\vc15\x64\php-7.= 3.33-ts\zend\zend_exceptions.c @ 222]

But this crash does not occur in Xdebug at all, but rather just in PHP.

Often when crashes happen at seemingly random locations, I would run my scripts with Zend's Memory Manager disabled, as it sometimes hides real issues. You can do that by exporting the USE_ZEND_ALLOC=0 environment variable. I believe on Windows that is done with set USE_ZEND_ALLOC=0. And with this set, then run the scripts again as before.

derick

2022-07-14 10:19

administrator   ~0006346

Hi,

did you manage to run the new test with set USE_ZEND_ALLOC=0 as I asked in the previous note?

cheers,
Derick

derick

2022-10-05 15:10

administrator   ~0006388

I can't reproduce this, and the original reporter did not provide the requested information. If this is still an issue, please reopen this issue, or file a new one.

ravage

2022-11-09 12:42

reporter   ~0006444

Sorry, Derick, for not getting backa t you with the requested information.

Today, I ran the affected test suite with various 3.1.x versions of Xdebug including the recently released 3.1.6, again.
It seems the new release fixed the issue, as I could run through the whole test suite with it.

So, up until 3.1.1 it worked, 3.1.2 up including 3.1.5 are affeced of this bug and 3.1.6 seems to fix it.

ravage

2022-12-07 12:22

reporter   ~0006463

Hi Derick,

After some hours of debugging, I found the culprit:

CakePHP 3.x App Template contains calls to xdebug_print_function_stack

CakePHP 4.x App Template does not contain any call to xdebug_print_function_stack (anymore)

xdebug_print_function_stack( string $message = "user triggered", int $options = 0 ) : void #
https://xdebug.org/docs/develop#xdebug_print_function_stack

It seems this function is buggy in some setups or call orders.

I don't have the faintest what this could be, but I am making a reasonable guess that some sequence does make this happen. It does seem to happen when an exception is thrown, which fetches a backtrace :

You were right on this.

For us, the workaround will be to disable this function call in our CakePHP 3.x applications and for CakePHP 4.x we will remove it as the CakePHP devs have done so.

Thank you & have some relaxing holidays with some nice Whisky.
Marc

Issue History

Date Modified Username Field Change
2022-06-08 17:13 ravage New Issue
2022-06-08 17:13 ravage Tag Attached: crash
2022-06-08 17:13 ravage Tag Attached: develop
2022-06-08 17:13 ravage Tag Attached: phpunit
2022-06-09 09:02 derick Assigned To => derick
2022-06-09 09:02 derick Status new => feedback
2022-06-09 09:02 derick Note Added: 0006329
2022-06-09 09:27 derick Note Edited: 0006329
2022-06-09 13:30 ravage Status feedback => assigned
2022-06-27 09:50 derick Status assigned => feedback
2022-06-27 09:50 derick Note Added: 0006335
2022-06-27 09:50 derick Note View State: 0006335: private
2022-06-27 09:51 derick Note View State: 0006335: public
2022-07-14 10:19 derick Note Added: 0006346
2022-10-05 15:10 derick Status feedback => resolved
2022-10-05 15:10 derick Resolution open => unable to reproduce
2022-10-05 15:10 derick Note Added: 0006388
2022-11-09 12:42 ravage Note Added: 0006444
2022-12-07 12:22 ravage Note Added: 0006463