php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21513 shutdown functions not executed if timed out
Submitted: 2003-01-08 02:53 UTC Modified: 2004-01-19 04:52 UTC
Votes:7
Avg. Score:4.7 ± 0.7
Reproduced:7 of 7 (100.0%)
Same Version:5 (71.4%)
Same OS:7 (100.0%)
From: ceeam at mail dot ru Assigned: zeev (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 4CVS, 5CVS OS: win32 (only)
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: ceeam at mail dot ru
New email:
PHP Version: OS:

 

 [2003-01-08 02:53 UTC] ceeam at mail dot ru
This problem is absolutely critical if you do DB cleanups, transactions processing or other similar things in shutdown functions. Can be especially bad if you need to commit/rollback transactions with persistent DB connections.

----------
<?php
function boo()
{
	...do_anything...; // never ever gets called
}

register_shutdown_function("boo");
set_time_limit(3); // not necessary, just to show the error sooner

for (;;) { // infinite loop to simulate long processing
}
?>
----------

Error message:

Fatal error: Maximum execution time of 3 seconds exceeded in c:\exp.php on line 10

Fatal error: Maximum execution time of 3 seconds exceeded in c:\exp.php on line 4

Does not depend on whether we run script as CGI/SAPI or CLI.

Report #14542 looks similar but is different IMHO.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-20 22:44 UTC] sniper@php.net
This script works just fine for me (using CLI):

<?php
 
error_log ("Start\n", 3, "test.log");

function boo()
{
  error_log ("Shutdown - function 'foo'\n", 3, "test.log");
}

register_shutdown_function("boo");

/* not necessary, just to show the error sooner */
set_time_limit(1); 

/* infinite loop to simulate long processing */
for (;;) {}

error_log ("\nEnd\n", 3, "test.log");

?>

In test.log I have now:
----cut----
Start
Shutdown - function 'foo'
----cut----

Which is the expected output.
Can you try this script?

 [2003-01-20 22:47 UTC] sniper@php.net
And this is related to http://bugs.php.net/bug.php?id=14542
(and maybe to http://bugs.php.net/bug.php?id=14251 ?)

 [2003-01-22 02:09 UTC] ceeam at mail dot ru
sniper@php.net:
> This script works just fine for me (using CLI):
> [skipped]

I tested your script. The output is:

PHP Fatal error:  Maximum execution time of 1 second exceeded in c:\exp.php on line 16
PHP Fatal error:  Maximum execution time of 1 second exceeded in c:\exp.php on line 7

"test.log" contains only one "Start" line.

I tried with both my own (pretty much cleaned up) php.ini and "recommended" php.ini.
I suspect it is only Windows-related problem.
 [2003-01-22 22:44 UTC] sniper@php.net
I can not reproduce this with PHP CGI/CLI/Apache DSO,
but Steph tested the script under windows and
got the same results as ceeam@mail.ru did so this is
definately a windows-only bug.

 [2003-08-04 00:24 UTC] wmeler at wp-sa dot pl
This is related to http://bugs.php.net/bug.php?id=16820 (see comment from 21 Jul 2:46am CDT)
You can find my patch at http://strony.wp.pl/wp/wmeler/.
These are old issues ...
 [2004-01-19 04:52 UTC] zeev@php.net
This bug has been fixed in CVS.

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.


 [2004-02-12 13:07 UTC] xuefer at 21cn dot com
compiled under cygwin
[Xuefer php4]$ ./sapi/cli/php.exe -v
PHP 4.3.5RC3-dev (cli) (built: Feb 13 2004 01:29:25)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

[Xuefer php4]$ make test
.........
PASS Testing register_shutdown_function() [tests/func/005.phpt]
<<- freeze here
it's running 005a.phpt


[Xuefer php4]$ sapi/cli/php -d max_execution_time=1 -r 'set_time_limit(1); for(;;) {}'
[Xuefer php4]$ sapi/cli/php test/func/005a.phpt
both is frozen
 [2010-04-17 17:40 UTC] reidrac at usebox dot net
I'm having the freeze problem in PHP 5.3.2 (was PASS in 5.3.1).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 07:01:27 2024 UTC