#57876 closed enhancement (invalid)
class WP_Fatal_Error_Handler can not handle memory limit errors
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | minor | Version: | |
Component: | Bootstrap/Load | Keywords: | |
Focuses: | Cc: |
Description
I found a potential issue with the following code:
<?php register_shutdown_function( array( $handler, 'handle' ) );
In the handle function, one of the first actions taken is:
<?php $error = $this->detect_error();
I believe this code may not execute properly if a PHP memory limit error has already occurred.
For example, in the Monolog library's ErrorHandler.php file, the handleFatalError function is registered as a shutdown function with the following code:
<?php register_shutdown_function([$this, 'handleFatalError']); $this->reservedMemory = str_repeat(' ', 1024 * $reservedMemorySize);
Then, in the handleFatalError function, the first action taken is to free up the reserved memory:
<?php $this->reservedMemory = ''; $lastError = error_get_last();
Therefore, it should be safe to assign $lastError in this context.
Please note that I have not yet conducted any tests to confirm whether this is a potential bug or whether the code can be enhanced. However, I wanted to report this issue to ensure that it is not overlooked and will continue to investigate further. If I find any additional information or evidence, I will update this report accordingly.
Change History (4)
#3
@
2 years ago
- Keywords close removed
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
- Version trunk deleted
Hi @amisiewicz, thanks for looking into this!
Let's close this ticket as invalid
for now, and if you find anything that suggests a change, feel free to reopen this ticket and post your findings.
I couldn't find any information on that topic. I just tested it out manually with this simple script:
My conclusion is that this is not a problem. We can still assign some variables (less memory to assign in php5.6, more in php7 and above), but php can still do it. I'm not sure why the monolog library does what it does.