php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24922 php CLI gets a segmentation fault in interactive mode with a simple foreach
Submitted: 2003-08-03 02:23 UTC Modified: 2003-08-10 19:15 UTC
From: llucax@php.net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5.0.0b2-dev OS: Linux 2.4.21 (debian sid)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: llucax@php.net
New email:
PHP Version: OS:

 

 [2003-08-03 02:23 UTC] llucax@php.net
Description:
------------
Just call php with -a option to enter in interactive mode. Then open php tags <? (short or long: <?php), write 'foreach' loop and php dies.
The list of modules is long:
./configure \
        --prefix=/usr/local/stow/php \
        --with-apxs=/usr/bin/apxs \
        --with-regex=php \
        --with-config-file-path=/usr/loca/stow/php/etc/php \
        --disable-rpath \
        --disable-debug \
        --enable-memory-limit \
        --with-layout=GNU \
        --enable-calendar \
        --enable-sysvmsg \
        --enable-sysvsem \
        --enable-sysvshm \
        --enable-wddx \
        --enable-track-vars \
        --enable-trans-sid \
        --enable-bcmath \
        --with-bz2 \
        --with-crack \
        --enable-ctype \
        --with-iconv \
        --enable-exif \
        --enable-filepro \
        --enable-ftp \
        --with-gettext \
        --enable-mbstring \
        --with-pcre-regex=/usr \
        --enable-shmop \
        --enable-sockets \
        --enable-wddx \
        --disable-xml \
        --with-expat-dir=/usr \
        --enable-yp \
        --with-zlib \
        --with-pgsql=shared,/usr \
        --with-kerberos=/usr \
        --with-openssl=/usr \
        --with-exec-dir=/usr/lib/php4/libexec \
        --disable-static \
        --enable-dba \
        --with-db4 \
        --with-gdbm \
        --with-inifile \
        --with-flatfile \
        --enable-dbase \
        --with-curl=shared,/usr \
        --with-dom=shared,/usr \
        --with-dom-xslt=shared,/usr \
        --with-dom-exslt=shared,/usr \
        --with-zlib-dir=/usr \
        --with-gd=shared \
        --with-jpeg-dir=shared,/usr \
        --with-xpm-dir=shared,/usr/X11R6 \
        --with-png-dir=shared,/usr \
        --with-imap=shared,/usr \
        --with-imap-ssl \
        --with-mcal=shared,/usr \
        --with-mcrypt=shared,/usr \
        --with-mhash=shared,/usr \
        --with-sqlite=shared,/usr \
        --with-mysql=shared,/usr \
        --with-unixODBC=shared,/usr \
        --with-recode=shared,/usr \
        --enable-xslt \
        --with-xsl=shared,/usr \
        --with-xslt-sablot=shared,/usr \
        --with-snmp=shared \
        --enable-ucd-snmp-hack \
        --with-ttf=shared,/usr \
        --with-mime-magic=/etc/mime-magic \
        --with-mysql=shared,/usr \
        --with-ncurses=shared,/usr \
        --with-readline=shared,/usr \
        --with-iodbc=shared,/usr \
        --enable-pcntl \
        --with-simplexml \
        --with-libxml-dir=/usr \
        --with-freetype-dir=shared,/usr


php.ini diff (compared to php.ini-recomended):
# diff -u php.ini-recommended php.ini 
--- src/php-5.0.0b1/php.ini-recommended 2003-06-18 12:19:16.000000000 -0300
+++ /usr/local/stow/php/etc/php/php.ini 2003-08-03 03:20:22.000000000 -0300
@@ -127,7 +127,7 @@
 ;       also. 
 ; Note: output_handler must be empty if this is set 'On' !!!!
 ;       Instead you must use zlib.output_handler.
-zlib.output_compression = Off
+zlib.output_compression = On
 
 ; You cannot specify additional output handlers if zlib.output_compression
 ; is activated here. This setting does the same as output_handler but in
@@ -289,7 +289,7 @@
 ; instead (see below).  Keeping display_errors enabled on a production web site
 ; may reveal security information to end users, such as file paths on your Web
 ; server, your database schema or other information.
-display_errors = Off
+display_errors = On
 
 ; Even when display_errors is on, errors that occur during PHP's startup
 ; sequence are not displayed.  It's strongly recommended to keep
@@ -307,7 +307,7 @@
 
 ; Do not log repeated messages. Repeated errors must occur in same file on same
 ; line until ignore_repeated_source is set true.
-ignore_repeated_errors = Off
+ignore_repeated_errors = On
 
 ; Ignore source of message when ignoring repeated messages. When this setting 
 ; is On you will not log errors with repeated messages from different files or
@@ -320,7 +320,7 @@
 report_memleaks = On
 
 ; Store the last error/warning message in $php_errormsg (boolean).
-track_errors = Off
+track_errors = On
 


Reproduce code:
---------------
homero:/home/luca# /usr/local/stow/php/bin/php -a
Interactive mode enabled

<? foreach(range(1,2) as $i);
Segmentation Fault



homero:/home/luca# /usr/local/stow/php/bin/php -a
Interactive mode enabled

<?
$a = array(1,2,3,4);
foreach ($a as $i);
Segmentation Fault

Expected result:
----------------
The foreach loop.

Actual result:
--------------
(gdb) run -a
Starting program: /usr/local/stow/php/bin/php -a
[New Thread 16384 (LWP 16009)]
Interactive mode enabled

<? foreach (range(1,2) as $i);

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 16009)]
0x0816a666 in execute (op_array=0x824d0d4) at /home/luca/src/php-5.0.0b1/Zend/zend_execute.c:1254
1254                    if (EX(opline)->handler(&execute_data, op_array TSRMLS_CC)) {
(gdb) bt
#0  0x0816a666 in execute (op_array=0x824d0d4) at /home/luca/src/php-5.0.0b1/Zend/zend_execute.c:1254
#1  0x0815449f in execute_new_code () at /home/luca/src/php-5.0.0b1/Zend/zend_execute_API.c:841
#2  0x08141520 in zendparse () at Zend/zend_language_parser.c:2174
#3  0x08144ffb in compile_file (file_handle=0xbffff990, type=2) at Zend/zend_language_scanner.c:3067
#4  0x0815b5d1 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /home/luca/src/php-5.0.0b1/Zend/zend.c:1013
#5  0x0812e246 in php_execute_script (primary_file=0xbffff990) at /home/luca/src/php-5.0.0b1/main/main.c:1695
#6  0x081757dc in main (argc=2, argv=0xbffffa24) at /home/luca/src/php-5.0.0b1/sapi/cli/php_cli.c:910
(gdb) 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-03 05:51 UTC] sniper@php.net
GDB backtrace:

[Switching to Thread 1024 (runnable)]
0x837b4c7 in execute (op_array=0x41c75b40) at /usr/src/web/php/php5/Zend/zend_execute.c:1199
1199                    if (EX(opline)->handler(&execute_data, op_array TSRMLS_CC)) {
(gdb) bt
#0  0x837b4c7 in execute (op_array=0x41c75b40) at /usr/src/web/php/php5/Zend/zend_execute.c:1199
#1  0x834e723 in execute_new_code () at /usr/src/web/php/php5/Zend/zend_execute_API.c:884
#2  0x8332326 in zendparse () at /usr/src/web/php/php5/Zend/zend_language_parser.y:151
#3  0x8336a34 in compile_file (file_handle=0xbffff620, type=2)
    at /usr/src/web/php/php5/Zend/zend_language_scanner.l:295
#4  0x835a2e3 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /usr/src/web/php/php5/Zend/zend.c:1028
#5  0x8313bce in php_execute_script (primary_file=0xbffff620) at /usr/src/web/php/php5/main/main.c:1573
#6  0x8395abf in main (argc=2, argv=0xbffff694) at /usr/src/web/php/php5/sapi/cli/php_cli.c:910
#7  0x4055b9cb in __libc_start_main (main=0x8394ce4 <main>, argc=2, argv=0xbffff694, init=0x80b5bc4 <_init>, 
    fini=0x84f4074 <_fini>, rtld_fini=0x4000aea0 <_dl_fini>, stack_end=0xbffff68c)
    at ../sysdeps/generic/libc-start.c:92

 [2003-08-10 19:15 UTC] helly@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Aug 15 14:00:03 2025 UTC