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: 2018-02-11 12:08 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: xmlscript at gmail dot com Assigned:
Status: Open Package: Scripting Engine problem
PHP Version: 7.2.2 OS: Fedora 27
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: xmlscript at gmail dot com
New email:
PHP Version: OS:

 

 [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
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Dec 02 10:01:24 2020 UTC