From:
Operating system: Debian 2.6.26-26lenny3
PHP version: 5.3.8
Package: Unknown/Other Function
Bug Type: Bug
Bug description:segfault while declaring function
Description:
------------
Although I do have a short code sample, I'm not sure where exactly or what
conditions causes the segfault; I am
unable to reproduce it myself. The backtrace indicates that this is indeed
where
the bug occurs.
The code sample below is an extract from a file that is included various
times
throughout a much larger
application. fhash is not defined anywhere else.
Test script:
---------------
if(!function_exists('fhash')) {
function fhash($file) {
system('optipng ' .
escapeshellarg(preg_replace('/src\/(\d+)\.(.+)$/', 'thumb/$1.png', $file))
. ' > /dev/null');
return sha1_file($file);
}
}
Expected result:
----------------
To ensure that fhash() is not declared multiple times as this file may be
included multiple times.
Actual result:
--------------
(gdb) bt
#0 0xb6f2ed5c in memcpy () from /lib/i686/cmov/libc.so.6
#0 0xb6f2ed5c in memcpy () from /lib/i686/cmov/libc.so.6
#1 0x084e9e17 in _zend_hash_add_or_update (ht=0x9bb7498, arKey=0xb49e3c98
"fhash", nKeyLength=6, pData=0x0,
nDataSize=144, pDest=0x0, flag=2,
__zend_filename=0x88aa40c "/home/<user>/php-5.3.8/Zend/zend_compile.c",
__zend_lineno=2956)
at /home/<user>/php-5.3.8/Zend/zend_hash.c:256
#2 0x084c3d48 in do_bind_function (opline=0xb49e88fc,
function_table=0x9bb7498,
compile_time=0 '\0')
at /home/<user>/php-5.3.8/Zend/zend_compile.c:2956
#3 0x0850aa49 in ZEND_DECLARE_FUNCTION_SPEC_HANDLER
(execute_data=0x9d79da8)
at /home/<user>/php-5.3.8/Zend/zend_vm_execute.h:586
#4 0x08508506 in execute (op_array=0x9d5ceac) at /home/<user>/php-
5.3.8/Zend/zend_vm_execute.h:107
#5 0x084dcf8d in zend_execute_scripts (type=8, retval=0x0, file_count=3)
at /home/<user>/php-5.3.8/Zend/zend.c:1236
#6 0x08472037 in php_execute_script (primary_file=0xbfc62428)
at /home/<user>/php-5.3.8/main/main.c:2284
#7 0x085a504e in main (argc=3, argv=0xbfc62594) at /home/<user>/php-
5.3.8/sapi/cgi/cgi_main.c:2112
(gdb) print (char *)executor_globals.active_op_array->filename
$2 = 0xb49e34d0 "/var/www/inc/instance-config.php"
(gdb) frame 4
#4 0x08508506 in execute (op_array=0x9d5ceac) at /home/<user>/php-
5.3.8/Zend/zend_vm_execute.h:107
107 if ((ret = EX(opline)->handler(execute_data TSRMLS_CC))
> 0) {
(gdb) frame 2
#2 0x084c3d48 in do_bind_function (opline=0xb49e88fc,
function_table=0x9bb7498,
compile_time=0 '\0')
at /home/<user>/php-5.3.8/Zend/zend_compile.c:2956
2956 if (zend_hash_add(function_table, opline-
>op2.u.constant.value.str.val, opline-
>op2.u.constant.value.str.len+1, function, sizeof(zend_function),
NULL)==FAILURE) {
(gdb) print (char*)opline->op2.u.constant.value.str.val
$1 = 0xb49e3c98 "fhash"
(gdb) frame 1
#1 0x084e9e17 in _zend_hash_add_or_update (ht=0x9bb7498, arKey=0xb49e3c98
"fhash", nKeyLength=6, pData=0x0,
nDataSize=144, pDest=0x0,
flag=2, __zend_filename=0x88aa40c "/home/<user>/php-
5.3.8/Zend/zend_compile.c", __zend_lineno=2956)
at /home/<user>/php-5.3.8/Zend/zend_hash.c:256
256 INIT_DATA(ht, p, pData, nDataSize);
--
Edit bug report at https://bugs.php.net/bug.php?id=55867&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=55867&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=55867&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=55867&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=55867&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=55867&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=55867&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=55867&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=55867&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=55867&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=55867&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=55867&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=55867&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=55867&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=55867&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=55867&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=55867&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=55867&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=55867&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=55867&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=55867&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=55867&r=mysqlcfg