From: webmaster at netnexus dot com
Operating system: OS X 10.4 (tiger)
PHP version: 5CVS-2005-08-12 (dev)
PHP Bug Type: Apache related
Bug description: zend_parse_parameters segfault on Apache 1.3.33 but runs fine
from the shell
Description:
------------
I'm unable to recieve parameters in my custom extension. I
followed the directions on the Zend website (http://
www.zend.com/php/internals/extension-writing1.php) for
setting up an extension and cut and copied the code directly
in. I then simply added the zend_parse_parameters function
so I could make the extension do something exciting. Upon
compilation I can run the script from the shell and it works
fine. I pass the extension a string and it returns it as
expected. Running the same script in the browser will
segfault. I've held off reporting this because I am new to
extension programming but I've searched for 2 days to no
avail and have run out of options.
Here's my setup-
OS X 1.4 (Tiger)
php -v
PHP 5.0.5-dev (cli) (built: Aug 12 2005 13:25:14) (DEBUG)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.4-dev, Copyright (c) 1998-2004 Zend
Technologies
httpd -V
Server version: Apache/1.3.33 (Darwin)
Server built: Mar 20 2005 15:08:27
Server's Module Magic Number: 19990320:16
Server compiled with....
-D EAPI
-D HAVE_MMAP
-D USE_MMAP_SCOREBOARD
-D USE_MMAP_FILES
-D HAVE_FCNTL_SERIALIZED_ACCEPT
-D HAVE_FLOCK_SERIALIZED_ACCEPT
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D DYNAMIC_MODULE_LIMIT=64
-D HARD_SERVER_LIMIT=2048
-D HTTPD_ROOT="/usr"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_PIDLOG="/var/run/httpd.pid"
-D DEFAULT_SCOREBOARD="/var/run/httpd.scoreboard"
-D DEFAULT_LOCKFILE="/var/run/httpd.lock"
-D DEFAULT_ERRORLOG="/var/log/httpd/error_log"
-D TYPES_CONFIG_FILE="/etc/httpd/mime.types"
-D SERVER_CONFIG_FILE="/etc/httpd/httpd.conf"
-D ACCESS_CONFIG_FILE="/etc/httpd/access.conf"
-D RESOURCE_CONFIG_FILE="/etc/httpd/srm.conf"
And my php configure options-
./configure --with-zlib-dir=/usr/local --with-libjpeg=/sw --
with-libtiff=/sw --with-libpng=/sw --with-gd --enable-
native-ttf --with-ttf --with-freetype-dir=/usr/local/lib/
freetype-2.1.9/ --with-mysql=/usr/local/mysql --with-xml --
with-apxs=/usr/sbin/apxs --enable-debug
Reproduce code:
---------------
if (ZEND_NUM_ARGS() != 1)
WRONG_PARAM_COUNT;
char* name = NULL;
int length;
// Crashes in zend_parse_parameters
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &length)
== FAILURE) {
RETURN_NULL();
}
Expected result:
----------------
The zend_parse_parameters function should recieve the calling
php functions parameters and continue it's executing normally.
Actual result:
--------------
It segfaults with this-
Program received signal EXC_BAD_ACCESS, Could not access
memory.
Reason: KERN_INVALID_ADDRESS at address: 0xfffffff8
0x00527154 in zend_parse_va_args ()
(gdb) bt
#0 0x00527154 in zend_parse_va_args ()
#1 0x00527278 in zend_parse_parameters ()
#2 0x000e0c80 in zif_imagesmoothline (ht=1,
return_value=0x3c06c8, this_ptr=0xbfffdf40,
return_value_used=0) at /Users/james/www/php5/extensions/
re_draw/re_draw.c:65
#3 0x02291668 in zend_do_fcall_common_helper
(execute_data=0xbfffe0e8, opline=0x1843d70,
op_array=0x3c0548) at /Users/james/Desktop/php5-
STABLE-200508121835/Zend/zend_execute.c:2760
#4 0x022923cc in zend_do_fcall_handler
(execute_data=0xbfffe0e8, opline=0x1843d70,
op_array=0x3c0548) at /Users/james/Desktop/php5-
STABLE-200508121835/Zend/zend_execute.c:2894
#5 0x02288774 in execute (op_array=0x3c0548) at /Users/
james/Desktop/php5-STABLE-200508121835/Zend/zend_execute.c:
1437
#6 0x0224dc24 in zend_execute_scripts (type=8, retval=0x0,
file_count=3) at /Users/james/Desktop/php5-
STABLE-200508121835/Zend/zend.c:1064
#7 0x021e5e7c in php_execute_script
(primary_file=0xbfffea50) at /Users/james/Desktop/php5-
STABLE-200508121835/main/main.c:1640
#8 0x0229a124 in apache_php_module_main (r=0x183de38,
display_source_mode=0) at /Users/james/Desktop/php5-
STABLE-200508121835/sapi/apache/sapi_apache.c:54
#9 0x0229b618 in send_php (r=0x183de38,
display_source_mode=0, filename=0x183fab8 "/Library/
WebServer/Documents/php5/extensions/test.php") at /Users/
james/Desktop/php5-STABLE-200508121835/sapi/apache/
mod_php5.c:630
#10 0x0229b6a4 in send_parsed_php (r=0x183de38) at /Users/
james/Desktop/php5-STABLE-200508121835/sapi/apache/
mod_php5.c:645
#11 0x0000dd18 in ap_invoke_handler ()
#12 0x00017dd4 in process_request_internal ()
#13 0x00017e54 in ap_process_request ()
#14 0x00006b60 in child_main ()
#15 0x00006dc4 in make_child ()
#16 0x000070f4 in perform_idle_server_maintenance ()
#17 0x000076d0 in standalone_main ()
#18 0x00007d74 in main ()
(gdb)
--
Edit bug report at http://bugs.php.net/?id=34108&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34108&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=34108&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=34108&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=34108&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=34108&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=34108&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=34108&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=34108&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=34108&r=support
Expected behavior: http://bugs.php.net/fix.php?id=34108&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=34108&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=34108&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=34108&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34108&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=34108&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=34108&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=34108&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=34108&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=34108&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=34108&r=mysqlcfg