Skip to content

Regression: Uncatchable exception #20714

Closed

Description

@greg0ire

Description

The following code:

<?php
function gen(): Generator
{
    try {
        yield 1;
    } finally {
    }
}

function process(): void
{
    $g = gen();
    foreach ($g as $_) {
        throw new Exception('ERROR');
    }
}

try {
    process();
} catch (Exception $e) {
    echo "Caught\n";
}

Resulted in this output:

Fatal error: Uncaught Exception: ERROR in /in/a8M88:15
Stack trace:
#0 /in/a8M88(20): process()
#1 {main}
  thrown in /in/a8M88 on line 15

Process exited with code 255.

But I expected this output instead:

Caught

This works with PHP 8.4.14, and it does not work with PHP 8.4.15

PHP Version

PHP 8.4.15 (cli) (built: Nov 18 2025 17:26:05) (NTS gcc x86_64)
Copyright (c) The PHP Group
Built by Fedora Project
Zend Engine v4.4.15, Copyright (c) Zend Technologies

Operating System

Fedora

Comparison between patch releases

php-8.4.14...php-8.4.15

Activity

  1. greg0ire commented on Dec 15, 2025

    @greg0ire
    ContributorAuthor

    This looks related: 1292037 👀
    PR: #20184

    Cc @iluuu1994

  2. self-assigned this
    on Dec 15, 2025
  3. iluuu1994 commented on Dec 15, 2025

    @iluuu1994
    Member

    Thanks, nice reproducer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions