php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81431 header_register_calback no longer allows die() to stop executing outputting
Submitted: 2021-09-11 10:17 UTC Modified: 2021-09-15 10:37 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: raoul_vanmaaren at live dot nl Assigned:
Status: Verified Package: Output Control
PHP Version: 8.0.10 OS:
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: raoul_vanmaaren at live dot nl
New email:
PHP Version: OS:

 

 [2021-09-11 10:17 UTC] raoul_vanmaaren at live dot nl
Description:
------------
In PHP 8.0.0 - 8.0.10, a die statement within the header_register_callback function will not prevent the trigger from being outputted. In previous versions this was the case. 

This is with the standard settings.

I am not sure if this is caused by the performance upgrades and if this is intended or not. However, I cannot find any documentation either.

Test script:
---------------
<?php
ob_start(); // make sure ob_level is set to 1

function callback()
{
    echo "In php 8.0.0 - 8.0.10, a die statement does prevent the trigger from being outputted: ";
    die();
}
header_register_callback("callback");

ob_end_clean();
echo "Trigger.";
echo "Execution died before this echo statement.";

Expected result:
----------------
In php 8.0.0 - 8.0.10, a die statement does prevent the trigger from being outputted: 

Actual result:
--------------
In php 8.0.0 - 8.0.10, a die statement does prevent the trigger from being outputted: Trigger.

Patches

bug81431.patch (last revision 2021-09-15 10:03 UTC by twosee@php.net)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-09-11 11:58 UTC] sjon@php.net
the output buffering calls don't seem to be relevant, see https://3v4l.org/Jsq2U
 [2021-09-12 19:14 UTC] raoul_vanmaaren at live dot nl
With output buffering on, for some reason, the expected result is produced. This is similar behaviour as previous versions. With output buffering off, it seems to behave in a different manner than the previous versions and prodduces the unexpected result.
https://3v4l.org/pv9jE
 [2021-09-15 10:03 UTC] twosee@php.net
The following patch has been added/updated:

Patch Name: bug81431.patch
Revision:   1631700233
URL:        https://bugs.php.net/patch-display.php?bug=81431&patch=bug81431.patch&revision=1631700233
 [2021-09-15 10:15 UTC] twosee@php.net
I think this is caused by the unwind_exit mechanism which was introduced in 8.0. I try to explain it briefly: PHP8.x+ versions use the exception mechanism to implement exit, so the C code will continue to execute. We can verify this behavior with this example: https://3v4l.org/43HMf.

I don’t know where to check for exceptions that would be more appropriate, but the behavior after applied the patch I provided is most in line with my intuition.
 [2021-09-15 10:37 UTC] twosee@php.net
-Status: Open +Status: Verified
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 11:01:30 2024 UTC