Bug #77638 [NEW]: var_export on an FFI\CData:* instance causes a segmentation fault
| From: | tandre@php.net | Date: | Mon, 18 Feb 2019 18:35:27 +0000 |
| Subject: | Bug #77638 [NEW]: var_export on an FFI\CData:* instance causes a segmentation fault | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-219631@lists.php.net to get a copy of this message | ||
From: tandre
Operating system: Linux
PHP version: Next Minor Version
Package: Reproducible crash
Bug Type: Bug
Bug description:var_export on an FFI\CData:* instance causes a segmentation fault
Description:
------------
Whenever var_export() is called on the result of FFI::new(), PHP
segfaults.
I think it's related to calling GC_PROTECT_RECURSION, *but the line
numbers in my build may be wrong*
```
553
GC_PROTECT_RECURSION(myht);
(gdb) bt
#0 0x0000000000944811 in php_var_export_ex (struc=0x7fffecc13100,
level=1, buf=0x7fffffffbf90) at /path/to/php-src/ext/standard/var.c:553
#1 0x0000000000944fe3 in zif_var_export (execute_data=0x7fffecc130b0,
return_value=0x7fffffffbfe0) at /path/to/php-src/ext/standard/var.c:622
#2 0x0000000000bb2b63 in ZEND_DO_ICALL_SPEC_RETVAL_UNUSED_HANDLER () at
/path/to/php-src/Zend/zend_vm_execute.h:649
```
Test script:
---------------
```
» php -a
Interactive shell
php > $x = FFI::new('int');
php > echo gettype($x);
object
php > echo get_class($x);
FFI\CData
php > var_dump($x);
object(FFI\CData:int32_t)#1 (1) {
["cdata"]=>
int(0)
}
php > var_export($x);
[1] 2615 segmentation fault php -a
```
Expected result:
----------------
Either dumps the type or throws an Exception/Error for being impossible
to dump
Actual result:
--------------
Segfaults
--
Edit bug report at https://bugs.php.net/bug.php?id=77638&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77638&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77638&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77638&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77638&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77638&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77638&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77638&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77638&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77638&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77638&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77638&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77638&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77638&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77638&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77638&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77638&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77638&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77638&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77638&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77638&r=mysqlcfg