php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20193 zend_get_parameters_ex segfault PHP on script end
Submitted: 2002-10-31 09:53 UTC Modified: 2002-11-11 18:17 UTC
From: drxor at intellaxiom dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.2.3 OS: Linux 2.4.12
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: drxor at intellaxiom dot com
New email:
PHP Version: OS:

 

 [2002-10-31 09:53 UTC] drxor at intellaxiom dot com
I have an extension which is working well in PHP 4.2.2 but when I compile it with PHP 4.2.3. The scripting engin crash on the end of the script several times. I comment out the zend_get_parameters_ex and put static parameters and the script work well.

There is the function in my extension (every function using parameter may crash PHP)

PHP_FUNCTION(ia_open)
{
   zval **spHost_arg, **spPort_arg;
   char *spHost = NULL;
   char *spPort = NULL;
    TIA_Stream* olStream;
    TIA_Stream* olResStream;
    TIA_Writer* olWriter;
    TIA_Reader* olReader;
    int sockfd;
    int nlRes=-1;
//If I use this it may crash PHP
#if 0
   if (ZEND_NUM_ARGS() != 2 || /*this part may crash PHP*/zend_get_parameters_ex(2, &spHost_arg, &spPort_arg) == FAILURE){
      WRONG_PARAM_COUNT;
   }
   convert_to_string_ex(spHost_arg);
   spHost = Z_STRVAL_PP(spHost_arg);
   convert_to_string_ex(spPort_arg);
   spPort = Z_STRVAL_PP(spPort_arg);
#else //It's ok with this code
   spHost = "xxxxx";
   spPort = "1111";
#endif
    sockfd = connecttounix();
    olStream = new TIA_Stream();
    olWriter = new TIA_Writer(olStream);
    olWriter->WriteInteger (knIA_Open);
    olWriter->WriteString (spHost);
    olWriter->WriteString (spPort);
    delete olWriter;
    olResStream = new TIA_Stream();
    if ( request(sockfd, olStream, olResStream) == 0)
    {
        olReader = new TIA_Reader(olResStream);
        nlRes = olReader->ReadInteger();
        delete olReader;
    }
    delete olResStream;
    delete olStream;
    disconnectfromunix(sockfd);
    RETURN_LONG (nlRes);
}

There is some output of PHPINFO
System Linux orion 2.4.12 #1 Wed Oct 24 03:59:50 EDT 2001 i686 unknown 
Build Date Oct 28 2002 09:54:34 
Configure Command './configure' '--with-mysql=/usr' '--with-apxs' '--with-interbase=/opt/interbase' '--with-gettext' '--with-xml' '--with-gd' '--with-png-dir=/usr' '--with-zlib-dir=/usr' '--with-imap=../imap-2002.RC8' '--with-imap-ssl=../imap-2002.RC8' 
Server API Apache 
Virtual Directory Support disabled 
Configuration File (php.ini) Path /usr/local/lib/php.ini 
Debug Build no 
Thread Safety disabled 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-31 14:04 UTC] iliaa@php.net
Could you please generate and post a backtrace of the crash (segmentation fault?).
 [2002-10-31 15:45 UTC] drxor at intellaxiom dot com
I run httpd with -X in gdb and here is a backtrace of the 
segfault. 
 
(gdb) run -X 
The program being debugged has been started already. 
Start it from the beginning? (y or n) y 
Starting program: /usr/sbin/httpd -X 
[New Thread 1024 (LWP 25507)] 
 
Program received signal SIGSEGV, Segmentation fault. 
[Switching to Thread 1024 (LWP 25507)] 
0x402bf82f in zend_do_pass_param (param=0xbfffd4dc, op=65, 
offset=2) at zend_compile.c:935 
935     zend_compile.c: No such file or directory. 
        in zend_compile.c 
(gdb) bt 
#0  0x402bf82f in zend_do_pass_param (param=0xbfffd4dc, 
op=65, offset=2) at zend_compile.c:935 
#1  0x402b5bad in zendparse () at 
zend_language_parser.c:2220 
#2  0x402b78d5 in compile_file (file_handle=0xbffff4e8, 
type=2) at zend_language_scanner.c:3021 
#3  0x402d5872 in zend_execute_scripts (type=8, 
retval=0x0, file_count=3) at zend.c:808 
#4  0x402e2ff6 in php_execute_script 
(primary_file=0xbffff4e8) at main.c:1383 
#5  0x402deb9e in apache_php_module_main (r=0x8180e14, 
display_source_mode=0) at sapi_apache.c:90 
#6  0x402df69e in send_php (r=0x8180e14, 
display_source_mode=0, filename=0x0) at mod_php4.c:575 
#7  0x402df702 in send_parsed_php (r=0x8180e14) at 
mod_php4.c:590 
#8  0x080553f9 in ap_invoke_handler () 
#9  0x0806a29f in ap_some_auth_required () 
#10 0x0806a306 in ap_process_request () 
#11 0x08061156 in ap_child_terminate () 
#12 0x08061331 in ap_child_terminate () 
#13 0x080614ac in ap_child_terminate () 
#14 0x08061b1c in ap_child_terminate () 
#15 0x0806236c in main () 
#16 0x400f12eb in __libc_start_main (main=0x8061fb4 
<main>, argc=2, ubp_av=0xbffff8f4, init=0x804f3a4 <_init>, 
fini=0x8099b4c <_fini>, 
    rtld_fini=0x4000c130 <_dl_fini>, stack_end=0xbffff8ec) 
at ../sysdeps/generic/libc-start.c:129
 [2002-11-11 14:54 UTC] drxor at intellaxiom dot com
I found that imap was causing the error. If I do not use 
imap and imap-ssl my ext is working well. But if I include 
the --with-imap and --with-imap-ssl then php is 
segfaulting. It's probably an incompatibility between imap 
extension and mine (probably others).
 [2002-11-11 18:17 UTC] sniper@php.net
If there's some 3rd party extension causing the crash and stock PHP does not crash -> not PHP bug.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Nov 28 19:00:02 2025 UTC