php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34108 zend_parse_parameters segfault on Apache 1.3.33 but runs fine from the shell
Submitted: 2005-08-12 21:55 UTC Modified: 2005-08-13 13:38 UTC
From: webmaster at netnexus dot com Assigned:
Status: Not a bug Package: Apache related
PHP Version: 5CVS-2005-08-12 (dev) OS: OS X 10.4 (tiger)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: webmaster at netnexus dot com
New email:
PHP Version: OS:

 

 [2005-08-12 21:55 UTC] webmaster at netnexus dot com
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) 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-12 22:00 UTC] tony2001@php.net
Please ask questions related to *your* custom extensions in pecl-dev maillist.
 [2005-08-13 10:08 UTC] webmaster at netnexus dot com
I was able to get my extension to work perfectly on OS X by 
compiling it into my php build instead of accessing it as a 
dynamic shared object. So I know it's not my custom 
extension that's causing the segfault..

Loading an extension from dl() or by adding it in your 
php.ini doesn't work on OS X 1.4 if zend_parse_parameters is 
present in the extension (aforementioned segfault).  Without 
it, it works just fine.

I changed the status of this bug to 'open' because it 
relates to php and not my custom extension.  Sorry if this 
is still the wrong place for this.
 [2005-08-13 10:29 UTC] rasmus@php.net
I build extensions on OSX all the time.  I don't know of a single extension that doesn't use zend_parse_parameters.  And I always load them from my php.ini file.

Can you reproduce the problem with an extension like pecl/apc, for example?  That is one I am building a dozen times every day.
 [2005-08-13 10:58 UTC] webmaster at netnexus dot com
Thank you for your reply.

I was able to compile it just fine. However, apache 
segfaults when php loads apc.so from php.ini. If I comment 
out that line it starts up just fine.

Here is the segfault info:

Program received signal EXC_BAD_ACCESS, Could not access 
memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000004
0x00529e44 in zend_hash_add_or_update ()
(gdb) bt
#0  0x00529e44 in zend_hash_add_or_update ()
#1  0x005303c8 in zend_register_ini_entries ()
#2  0x002622e8 in zm_startup_apc (type=-1, module_number=19) 
at /Users/james/Desktop/APC-3.0.6/php_apc.c:149
#3  0x022546ec in zend_register_module_ex (module=0x377850) 
at /Users/james/Desktop/php5-STABLE-200508121835/Zend/
zend_API.c:1251
#4  0x0214cb54 in php_dl (file=0x309738, type=1, 
return_value=0xbffff5f0) at /Users/james/Desktop/php5-
STABLE-200508121835/ext/standard/dl.c:216
#5  0x021ee584 in php_load_function_extension_cb 
(arg=0x309738) at /Users/james/Desktop/php5-
STABLE-200508121835/main/php_ini.c:248
#6  0x0223ed48 in zend_llist_apply (l=0x233a8f0, 
func=0x21ee550 <php_load_function_extension_cb>) at /Users/
james/Desktop/php5-STABLE-200508121835/Zend/zend_llist.c:191
#7  0x021eee20 in php_ini_delayed_modules_startup () at /
Users/james/Desktop/php5-STABLE-200508121835/main/php_ini.c:
552
#8  0x021e66dc in php_module_startup (sf=0x23256b0, 
additional_modules=0x2325a38, num_additional_modules=1) at /
Users/james/Desktop/php5-STABLE-200508121835/main/main.c:
1469
#9  0x0229b8ec in php_apache_startup (sapi_module=0x23256b0) 
at /Users/james/Desktop/php5-STABLE-200508121835/sapi/
apache/mod_php5.c:270
#10 0x0229d09c in php_init_handler (s=0x1802648, 
p=0x1802610) at /Users/james/Desktop/php5-
STABLE-200508121835/sapi/apache/mod_php5.c:904
#11 0x0000ff60 in ap_init_modules ()
#12 0x00007d54 in main ()
 [2005-08-13 13:38 UTC] tony2001@php.net
Please, use pecl-dev, this is not a support forum or a mailing list.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 14:01:29 2024 UTC