Skip to content

Error when killing script: Object of class UnwindExit could not be converted to string #11821

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rbro opened this issue Jul 29, 2023 · 2 comments

Comments

@rbro
Copy link

rbro commented Jul 29, 2023

Description

I am running PHP 8.2.8 and PHP 8.3.0 Beta 1, and at times, I get this error when killing a cli script:

Object of class UnwindExit could not be converted to string

It's been tricky to reproduce, but I can intermittently get the error by:

  1. Unzip attached code.zip.
  2. Run: php -n test.php
  3. Immediately press Ctrl-C.

If no errors appear, repeat running the script and pressing Ctrl-C.

The error I get is:

Warning: Uncaught Error: Object of class UnwindExit could not be converted to string in /tmp/test/a.php:2
Stack trace:
#0 /tmp/test/test.php(4): require()
#1 /tmp/test/test.php(14): {closure}('a')
#2 {main}
  thrown in /tmp/test/a.php on line 2

Fatal error: During class fetch: Uncaught  in /tmp/test/a.php on line 2

I believe the error comes up when the script is killed while one of the classes is being loaded.

Please let me know if I can provide more information to narrow it down.

Thanks for your help.

PHP Version

PHP 8.2.8 and PHP 8.3.0 Beta 1

Operating System

Linux

@nielsdos
Copy link
Member

When the exit; line is executed, an internal UnwindExit exception is thrown.
This happens during the linking of class a where it tries to link to trait b.
However, linking to b fails and this causes report_class_fetch_error to be called. In report_class_fetch_error the check for EG(exception) will succeed because an instance of ce_unwind_exit is stored in there. In zend_exception_uncaught_error it tries to convert the exception to a string, which fails because UnwindExit doesn't have a way to convert it to a string, leading to the strange combination of warning + fatal error you see.

@tjurczak
Copy link

I have a similar error in Symfony Messenger consume process. Is there any news about it? does it require some investigation in the application source code or is it something to fix in the PHP source?

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

No branches or pull requests

3 participants