derickr / vld

BSD 2-Clause "Simplified" License
464 stars 87 forks source link

Segmentation Fault #53

Closed scottarc closed 4 years ago

scottarc commented 4 years ago

PHP version:

$ php -v
PHP 7.4.1 (cli) (built: Dec 18 2019 15:00:01) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.1, Copyright (c), by Zend Technologies

Terminal output:

$ php -dvld.active=1 utils.php 
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /censored/utils.php
function name:  (null)
number of ops:  1
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  24     0  E > > RETURN                                                   1

branch: #  0; line:    24-   24; sop:     0; eop:     0; out0:  -2
path #1: 0, 
Function dump:
Finding entry points
Branch analysis from position: 0
Segmentation fault

Test file:

<?php
/**
 * Prevent Travis CI's breaking change in var_dump() behavior from breaking tests.
 *
 * @param mixed $foo
 */
function dump($foo)
{
    switch (gettype($foo)) {
        case 'boolean':
            echo 'bool(' . ($foo ? 'true' : 'false') . ')', PHP_EOL;
            break;
        case 'string':
            echo 'string(' . strlen($foo) . ') "' . $foo . '"', PHP_EOL;
            break;
        case 'integer':
            echo 'int(' . $foo . ')', PHP_EOL;
            break;
        case 'double':
            echo 'float(' . $foo . ')', PHP_EOL;
            break;
    }
}

Output from gdb:

$ gdb --args php -d vld.active=1 utils.php 
GNU gdb (Debian 8.2.1-2+b3) 8.2.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from php...(no debugging symbols found)...done.
(gdb) run
Starting program: /usr/bin/php -d vld.active=1 utils.php
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /censored/utils.php
function name:  (null)
number of ops:  1
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  24     0  E > > RETURN                                                   1

branch: #  0; line:    24-   24; sop:     0; eop:     0; out0:  -2
path #1: 0, 
Function dump:
Finding entry points
Branch analysis from position: 0

Program received signal SIGSEGV, Segmentation fault.
vld_find_jumps (opa=opa@entry=0x7ffff5003018, position=position@entry=2, jump_count=jump_count@entry=0x7fffffffa4f8, jumps=jumps@entry=0x7fffffffa500)
    at /tmp/pear/temp/vld/srm_oparray.c:936
936 /tmp/pear/temp/vld/srm_oparray.c: No such file or directory.
derickr commented 4 years ago

Thanks for the detailed report! This was already fixed in GIT, and I've just made a release (0.17.0) that contains this fix.

cheers, Derick