View Issue Details

IDProjectCategoryView StatusLast Update
0002224XdebugUncategorizedpublic2023-12-08 16:10
Reporterkraplax Assigned Toderick  
Status resolvedResolutionno change required 
Platformx86OSLinuxOS Versionany
Product Version3.3.0 
Summary0002224: XDebug conflicts with PHP FFI extension - crashes on FFI::new() call

For PHP 8.2 and 8.3 when XDebug 3.3.0 is installed, the FFI extension crashes on the call to FFI::new() method:

Fatal error: Uncaught FFI\ParserException: unexpected '<EOF>' at line 1 in /var/www/html/test.php on line 1

FFI\ParserException: unexpected '<EOF>' at line 1 in /var/www/html/test.php on line 1

Call Stack:
    0.0003     458704   1. {main}() /var/www/html/test.php:0
    0.0003     458832   2. FFI->new($type = '') /var/www/html/test.php:1

It doesn't affect 8.1 and older versions. Cannot be reproduced with XDebug 3.2.2.

Steps To Reproduce

Install PHP 8.2 or PHP 8.3
Install FFI extension
Install XDebug 3.3.0 from PECL

Run following code example:

$ffi = FFI::cdef("", "");
Tagscrash, ffi, php8.2, php8.3
Attached Files
xdebug_ffi.dockerfile (275 bytes)   
FROM php:8.2-cli

RUN apt update && apt install -y libffi-dev

RUN docker-php-ext-install -j$(nproc) ffi

RUN pecl install xdebug-3.3.0 && docker-php-ext-enable xdebug

RUN echo '<?php $ffi = FFI::cdef("", ""); $ffi->new("int");' > test.php

CMD ["php", "test.php"]
xdebug_ffi.dockerfile (275 bytes)   
Operating System
PHP Version8.2.0-8.2.9



2023-12-08 16:10

administrator   ~0006716

This turned out not to be a bug with Xdebug, but with how FFI interacts with observers.

In a clean PHP compile, compiled with, and running with your test script in /tmp/ffi.php:

./configure --enable-debug --disable-all --enable-zend-test --with-ffi
make clean && make
sapi/cli/php -n /tmp/ffi-test.php

I get the same error (please note that I use -n to disable the standard php.ini file):

&lt;!-- init '/tmp/ffi.php' -->
&lt;file '/tmp/ffi.php'>
  &lt;!-- init FFI::cdef() -->
  &lt;!-- init FFI::new() -->
    &lt;!-- Exception: FFI\ParserException -->
  &lt;!-- Exception: FFI\ParserException -->
&lt;/file '/tmp/ffi.php'>
&lt;!-- init Error::__toString() -->
  &lt;!-- init Error::getTraceAsString() -->

Fatal error: Uncaught FFI\ParserException: unexpected '&lt;EOF>' at line 1 in /tmp/ffi.php:3
Stack trace:
#0 /tmp/ffi.php(3): FFI->new('')
#1 {main}
  thrown in /tmp/ffi.php on line 3

I've filed a bug with PHP:

Issue History

Date Modified Username Field Change
2023-12-07 18:00 kraplax New Issue
2023-12-07 18:00 kraplax Tag Attached: crash
2023-12-07 18:00 kraplax Tag Attached: ffi
2023-12-07 18:00 kraplax Tag Attached: php8.2
2023-12-07 18:00 kraplax Tag Attached: php8.3
2023-12-07 18:00 kraplax File Added: xdebug_ffi.dockerfile
2023-12-08 16:10 derick Assigned To => derick
2023-12-08 16:10 derick Status new => resolved
2023-12-08 16:10 derick Resolution open => no change required
2023-12-08 16:10 derick Note Added: 0006716