View Issue Details

IDProjectCategoryView StatusLast Update
0002090XdebugUncategorizedpublic2022-06-06 15:28
ReporterNiNjA Assigned To 
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionfixed 
Product Version3.1.4 
Fixed in Version3.1.5 
Summary0002090: Segfault in __callStatic() after FFI initialization
Description

When I run the attached index.php script from command line or through nginx + php-fpm (and the debugger is attached to PhpStorm) the php process crashes.
This is the command I run and the output I get:

% PHP_IDE_CONFIG=serverName=test XDEBUG_SESSION=1 php index.php
works1 called
works2 called
Hello world!
zsh: segmentation fault (core dumped) PHP_IDE_CONFIG=serverName=test XDEBUG_SESSION=1 php index.php

I expected to get this output without any segfault:
works1 called
works2 called
Hello world!
breaks called

I'm not 100% sure that this is an xdebug issue, however, it works just fine if I disable xdebug. It looks like that after FFI has been initialized, xdebug crashes when __callStatic() is about to be executed. I'm not that familiar with C and gdb, so I have not investigated this much further, but please let me know if you need any additional information. Note that this fails on both PHP 8.1.4 and 8.1.5, but I couldn't select 8.1.5 from the list.

Steps To Reproduce
  1. Ensure an xdebug configuration is up and running
  2. Enable FFI extension
  3. Run the script either through php-fpm or cli
  4. Ensure the debugger attaches to the host process (e.g. PhpStorm)
  5. Make the script run to end
  6. Segfault should occur before the Test::breaks() line
Tagsffi
Operating SystemArch Linux
PHP Version8.1.0-8.1.4

Activities

NiNjA

2022-05-10 20:26

reporter   ~0006292

Added attachments:

  • index.php (test script)
  • systemd-coredump output

derick

2022-05-11 09:02

administrator   ~0006295

Hi,

This does look like something dubious going on in ext/FFI, but there is a harmless workaround (an extra guard) to at least hide this problem within Xdebug, for which I have made a pull request:
https://github.com/xdebug/xdebug/pull/837

Once CI is happy, I'll merge it.

Thanks for your detailed report.

cheers,
Derick