php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75950 when zend.assertions=-1, and assert(sleep(5)); assertions is NOT zero-cost.
Submitted: 2018-02-11 08:37 UTC Modified: 2021-02-14 04:22 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: xmlscript at gmail dot com Assigned: cmb (profile)
Status: No Feedback Package: Scripting Engine problem
PHP Version: 7.2.2 OS: Fedora 27
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2018-02-11 08:37 UTC] 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.  :(
?>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-11 08:43 UTC] 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 12:08 UTC] cmb@php.net
-Package: PHP Language Specification +Package: Scripting Engine problem
 [2018-02-14 06:57 UTC] pslacerda+php at gmail dot com
I couldn't reproduce this error.
 [2018-02-15 17:04 UTC] 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-15 18:05 UTC] 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
 [2021-02-03 11:14 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-02-03 11:14 UTC] cmb@php.net
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>
 [2021-02-14 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Nov 29 21:03:58 2022 UTC