Skip to content

Stale EG(opline_before_exception) pointer through eval #20183

Closed

Description

@iluuu1994

Description

Credits to @vi3tL0u1s et al. for the original report.

The following code:

class A {
    function __destruct() {
        // Store dangling pointer in EG(opline_before_exception)
        eval('try { throw new Error(); } catch (Error $e) {}');
        debug_print_backtrace();
    }
}

B::$b = new A;

Resulted in this output:

heap-use-after-free

But I expected this output instead:

#0 %s(10): A->__destruct()

Fatal error: Uncaught Error: Class "B" not found in %s:10
Stack trace:
#0 {main}
  thrown in %s on line 10

PHP Version

PHP 8.3

Operating System

No response

Activity

  1. added a commit that references this issue on Oct 21, 2025
    c46b548
  2. added a commit that references this issue on Oct 27, 2025
    1292037
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions