Skip to content

Runtime: set_exception_handler() / restore_exception_handler() VM stack (#3146) - #3887

Merged
PurHur merged 3 commits into
masterfrom
agent/issue-3146-exception-handler
May 31, 2026
Merged

PurHur merged 3 commits into
masterfrom
agent/issue-3146-exception-handler

Conversation

@PurHur

@PurHur PurHur commented May 31, 2026

Copy link
Copy Markdown
Owner

Summary

  • Implements set_exception_handler() and restore_exception_handler() with a VM handler stack (ExceptionHandlerStack) wired into uncaught-exception dispatch in lib/VM.php.
  • Supports closure and string-function callbacks; handler returning false falls through to the previous handler (Zend zend_exceptions.c parity).
  • Adds compliance .phpt coverage; JIT umbrella skips these VM-only builtins until LLVM lowering exists.

php-src reference

  • ext/standard/basic_functions.cPHP_FUNCTION(set_exception_handler), restore_exception_handler
  • Zend/zend_exceptions.c — uncaught handler chain

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter exception_handler'

Closes #3146

Made with Cursor

PurHur and others added 3 commits May 31, 2026 09:10
…ck (#3146)

Wire uncaught-exception dispatch through a handler stack matching Zend
zend_exceptions.c: closures and string callbacks, nested restore, and
false return fallthrough before default fatal handling.

Co-authored-by: Cursor <cursoragent@cursor.com>
Walk the handler stack by index during uncaught dispatch so handlers
that return false remain registered (Zend zend_exceptions.c parity).

Co-authored-by: Cursor <cursoragent@cursor.com>
Guards set_exception_handler('func_name') dispatch alongside closure handlers.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur force-pushed the agent/issue-3146-exception-handler branch from 274c097 to 4a56ac8 Compare May 31, 2026 09:10
@PurHur
PurHur merged commit 0d6117e into master May 31, 2026
@PurHur
PurHur deleted the agent/issue-3146-exception-handler branch May 31, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Runtime: set_exception_handler() / restore_exception_handler() (ext/standard parity)

1 participant