Skip to content

Regression: return-type TypeError getTrace() empty — missing callee function frame (Zend/zend_exceptions.c) #14369

Closed

Description

@PurHur

Summary

When a user function or method violates its declared return type, Zend populates TypeError::getTrace() with a frame for the failing callable (g, m, …). VM returns an empty trace array ([]), breaking Exception::getTrace(), getTraceAsString(), and debug tooling that expects the innermost frame.

Repro covers generator return-type violations and ordinary method return-type violations.

php-src reference

  • Zend/zend_exceptions.c — zend_throw_return_type_error, trace frame assembly
  • Zend/zend_execute.c — return-type enforcement sites

PHP implementation target

Repro

php bin/vm.php test/repro/maintainer_gap_return_type_error_trace.php
# VM: fail generator trace: [] / fail method trace: []
# Zend: ok

test/repro/maintainer_gap_return_type_error_trace.php

Expected (php-src-strict)

  • getTrace()[0]['function'] is the violating callable name
  • Fatal uncaught stack trace lists caller frame (g() / C->m()), not only {main}

Done when

  • Repro green on VM
  • JIT/AOT agree when those backends enforce return types
  • No new C beyond thin ABI if trace data already exists in VM frames

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jul 1, 2026
  2. PurHur commented on Jul 1, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Runtime → PHP — batch (issues #14369)

  3. PurHur commented on Jul 1, 2026

    @PurHur
    OwnerAuthor

    Merged #14372 — return-type TypeError getTrace() now includes violating callable frame on VM bridge throws. Verification: maintainer_gap_return_type_error_trace.php + return_type_error_trace.phpt green.

  4. PurHur commented on Jul 1, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — batch (issues #13079, #14369)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions