php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54924 assert.active is not being reset upon request shutdown
Submitted: 2011-05-25 13:48 UTC Modified: 2011-05-26 20:17 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: andreas dot streichardt at gmail dot com Assigned: iliaa (profile)
Status: Closed Package: Unknown/Other Function
PHP Version: 5.3.6 OS: Linux
Private report: No CVE-ID: None
 [2011-05-25 13:48 UTC] andreas dot streichardt at gmail dot com
Description:
------------
The assert related functions are saving their state in a global structure. The 
problem is that the assert state is not being reset in the RSHUTDOWN function 
and thus the assert state of the last request will be used for the next request.

Example: If assert is active by default (php.ini assert.active) and you set it 
to false via assert_options this works fine. However on the next request the 
default will be that assert is not active.


The fix is to add

  ASSERTG(active)=INI_INT("assert.active");

to asserts RSHUTDOWN function.

I am using the FastCGI SAPI.

Test script:
---------------
var_dump(assert_options(ASSERT_ACTIVE));
assert(false);
var_dump(assert_options(ASSERT_ACTIVE,1));
assert(false);
var_dump(assert_options(ASSERT_ACTIVE,0));
assert(false);


Expected result:
----------------
int(1) 
Warning: assert() [function.assert]: Assertion failed in xxx.php on line 3
int(1) 
Warning: assert() [function.assert]: Assertion failed in xxx.php on line 5
int(1)

Actual result:
--------------
First request:

int(1) 
Warning: assert() [function.assert]: Assertion failed in xxx.php on line 3
int(1) 
Warning: assert() [function.assert]: Assertion failed in xxx.php on line 5
int(1)

Second request (make sure you hit the same pid):

int(0) int(0) 
Warning: assert() [function.assert]: Assertion failed in xxx.php on line 5
int(1)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-05-25 14:15 UTC] steemann at globalpark dot de
Same issue for assert.warning (ASSERT_WARNING).
The value is not reset to the ini setting value at the end of each request if PHP child processes are reused (e.g. in fastcgi mode).
Probably the same for assert.bail and friends.
 [2011-05-26 20:17 UTC] iliaa@php.net
Automatic comment from SVN on behalf of iliaa
Revision: http://svn.php.net/viewvc/?view=revision&revision=311451
Log: Fixed bug #54924 (assert.* is not being reset upon request shutdown).
 [2011-05-26 20:18 UTC] iliaa@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: iliaa
 [2011-05-26 20:18 UTC] iliaa@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2012-04-18 09:50 UTC] laruence@php.net
Automatic comment on behalf of iliaa
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c5e56ff90c1051bf6a8765fcf7b627b28b2459f5
Log: Fixed bug #54924 (assert.* is not being reset upon request shutdown).
 [2012-07-24 23:41 UTC] rasmus@php.net
Automatic comment on behalf of iliaa
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c5e56ff90c1051bf6a8765fcf7b627b28b2459f5
Log: Fixed bug #54924 (assert.* is not being reset upon request shutdown).
 [2013-11-17 09:38 UTC] laruence@php.net
Automatic comment on behalf of iliaa
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c5e56ff90c1051bf6a8765fcf7b627b28b2459f5
Log: Fixed bug #54924 (assert.* is not being reset upon request shutdown).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 05:01:29 2024 UTC