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

From: Date: Wed, 03 Feb 2021 11:14:53 +0000
Subject: Bug #75950 [Opn->Fbk]: 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-231904@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
 Updated by:         cmb@php.net
 Reported by:        xmlscript at gmail dot com
 Summary:            when zend.assertions=-1, and assert(sleep(5));
                     assertions is NOT zero-cost.
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Fedora 27
 PHP Version:        7.2.2
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

I cannot reproduce this with PHP-7.4 even when using a shared
OPcache.  Can you still reproduce with any of the actively
supported PHP versions[1]?

[1] <https://www.php.net/supported-versions.php>


Previous Comments:
------------------------------------------------------------------------
[2018-02-15 18:05:22] xmlscript at gmail dot com

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

------------------------------------------------------------------------
[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


Thread (1 message)

  • cmb@php.net
  • Unknown Message
    • cmb@php.net
« previous php.bugs (#231904) next »