Bug #70006 [Asn->Csd]: cli - function with default arg = STDOUT crash output

From: Date: Tue, 07 Jul 2015 11:26:11 +0000
Subject: Bug #70006 [Asn->Csd]: cli - function with default arg = STDOUT crash output
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194172@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70006&edit=1

 ID:                 70006
 Updated by:         laruence@php.net
 Reported by:        simon dot minotto at gmail dot com
 Summary:            cli - function with default arg = STDOUT crash
                     output
-Status:             Assigned
+Status:             Closed
 Type:               Bug
 Package:            *General Issues
 Operating System:   ubuntu 15.04 server
 PHP Version:        7.0.0alpha2
 Assigned To:        dmitry
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7af4e6d02d678b9e31c192e8adfc3bb9d6277f5a
Log: Fixed bug #70006 (cli - function with default arg = STDOUT crash output).


Previous Comments:
------------------------------------------------------------------------
[2015-07-07 10:39:59] laruence@php.net

an quick fix is: 

diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index fc92494..1386c95 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -555,11 +555,9 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change,
zend_clas
 		zend_throw_error(zend_ce_error, "Cannot declare self-referencing constant
'%s'", Z_STRVAL_P(p));
 		return FAILURE;
 	} else if (Z_TYPE_P(p) == IS_CONSTANT) {
-		int refcount;

 		SEPARATE_ZVAL_NOREF(p);
 		MARK_CONSTANT_VISITED(p);
-		refcount =  Z_REFCOUNTED_P(p) ? Z_REFCOUNT_P(p) : 1;
 		if (Z_CONST_FLAGS_P(p) & IS_CONSTANT_CLASS) {
 			ZEND_ASSERT(EG(current_execute_data));
 			if (inline_change) {
@@ -640,7 +638,7 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_clas
 			zval_opt_copy_ctor(p);
 		}

-		if (Z_REFCOUNTED_P(p)) Z_SET_REFCOUNT_P(p, refcount);
+		/* if (Z_REFCOUNTED_P(p)) Z_SET_REFCOUNT_P(p, refcount); */
 	} else if (Z_TYPE_P(p) == IS_CONSTANT_AST) {
 		zval tmp;


however I am  not sure why SET_REFCOUNT_P here..

------------------------------------------------------------------------
[2015-07-07 09:21:37] simon dot minotto at gmail dot com

Description:
------------
using php in cli mode


With following code : 
<?php

function foo1($stream = STDOUT)
{
  //do nothing
}
echo "before\n";
foo1();
echo "after\n";


Excepted result : display
before
after


Result with php7 : 
before


Work fine with php 5.X


azureuser@php7test1:/mnt/eztv$ php -v
PHP 7.0.0alpha2 (cli) (built: Jul  7 2015 04:58:33) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies


'./configure' '--with-apxs2=/usr/bin/apxs' '--with-mysqli'
'--enable-soap' '--enable-sockets' '--enable-sysvsem'
'--with-xsl' '--enable-zip' '--enable-mbstring'
'--with-curl' '--with-mcrypt' '--enable-ftp' '--with-gd'
'--with-jpeg-dir=/usr/lib' '--enable-exif' '--with-openssl'
'--enable-pcntl'

Test script:
---------------
<?php

function foo1($stream = STDOUT)
{
  //do nothing
}
echo "before\n";
foo1();
echo "after\n";


Excepted result : display
before
after

Expected result:
----------------
before
after

Actual result:
--------------
before


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=70006&edit=1


Thread (3 messages)

« previous php.bugs (#194172) next »