View Issue Details

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

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:

<?php
$ffi = FFI::cdef("", "libc.so.6");
$ffi->new("int");
Tagscrash, ffi, php8.2, php8.3
Operating System
PHP Version8.2.0-8.2.9

Activities

derick

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  -dzend_test.observer.enabled=1 -dzend_test.observer.observe_all=1 /tmp/ffi-test.php

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

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

Fatal error: Uncaught FFI\ParserException: unexpected '<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: https://github.com/php/php-src/issues/12905