Bug #75950 [Com]: when zend.assertions=-1, and assert(sleep(5)); assertions is NOT zero-cost.

From: Date: Thu, 15 Feb 2018 18:05:23 +0000
Subject: Bug #75950 [Com]: when zend.assertions=-1, and assert(sleep(5)); assertions is NOT zero-cost.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213976@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75950&edit=1 ID: 75950 Comment by: xmlscript at gmail dot com Reported by: xmlscript at gmail dot com Summary: when zend.assertions=-1, and assert(sleep(5)); assertions is NOT zero-cost. Status: Open Type: Bug Package: Scripting Engine problem Operating System: Fedora 27 PHP Version: 7.2.2 Block user comment: N Private report: N New Comment: Reproduce this error need write real script file: ```script.php <?php $a=1;assert($a++);echo $a; ``` shell# php -S localhost:88 shell# curl http://localhost:88/script.php 2 shell# php -f script.php 2 shell# echo '<?php $a=1;assert($a++);echo $a;' | php -d zend.assertions=-1 2 =================================================== php -a and php -r is OK: shell# php -d zend.assertions=-1 -a Interactive shell php > $a=1;assert($a++);echo $a; 1 shell# php -d zend.assertions=-1 -r '$a=1;assert($a++);echo $a;' 1 Previous Comments: ------------------------------------------------------------------------ [2018-02-15 17:04:16] xmlscript at gmail dot com @pslacerda <?php assert_options(ASSERT_ACTIVE, false); $var = 1; // The expectation is always equal to 1, When zend.assertions=-1 and assert.active=Off assert('$var++'); echo $var; // return 1, good. assert($var++); echo $var; // return 2, No! It should be 1 assert('$var++'); echo $var; // 2 assert($var++); echo $var; // 3 ?> output: 1223 EXPECT: 1111 ------------------------------------------------------------------------ [2018-02-14 06:57:19] pslacerda+php at gmail dot com I couldn't reproduce this error. ------------------------------------------------------------------------ [2018-02-11 08:43:32] xmlscript at gmail dot com <?php /** * php-fpm 7.2.2 * zend.assertions = -1 */ var_dump( ini_get('zend.assertions') ); // return -1 assert_options(ASSERT_ACTIVE, false); assert( 'sleep(5)' ); //with string, assertion code will not be generated, and throwed an "Deprecated: assert(): Calling assert() with a string argument is deprecated in ..." assert( sleep(5) ); //really waited for 5 seconds, is NOT assertions zero-cost. :( ?> ------------------------------------------------------------------------ [2018-02-11 08:37:45] xmlscript at gmail dot com Description: ------------ <?php /** * php-fpm 7.2.2 * zend.assertions = -1 */ var_dump( ini_get('zend.assertions') ); // return -1 assert_options(ASSERT_ACTIVE, true); assert( 'sleep(5)' ); //with string, assertion code will not be generated, and throwed an "Deprecated: assert(): Calling assert() with a string argument is deprecated in ..." assert( sleep(5) ); //really waited for 5 seconds, is NOT assertions zero-cost. :( ?> ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75950&edit=1

« previous php.bugs (#213976) next »