Skip to content
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.

set_exception_handler disables try-catch #493

Closed
sirsnyder opened this issue Oct 5, 2015 · 1 comment
Closed

set_exception_handler disables try-catch #493

sirsnyder opened this issue Oct 5, 2015 · 1 comment

Comments

@sirsnyder
Copy link
Collaborator

Hi @krakjoe, during the migration from pthreads 2 to 3, I stumbled about this unexpected behaviour. If the set_exception_handler is set within a Thread::run, the catch of a try-catch gets ignored.

class Thrower extends Thread
    {
        public function run()
        {
            set_exception_handler(function($message)
            {
                var_dump('Thread ExceptionHandler', $message);

                flush();
            });

            try
            {
                throw new \Exception();
            }
            catch(Exception $e) // ignored
            {
                var_dump('CatchedException', $e);
            }
        }
    }

    $objThrower = new Thrower();
    $objThrower->start();
    $objThrower->join();

If set_exception_handler is not set, everything works fine.

  • win7
  • pthreads 3.0.7
  • php 7 RC 4
krakjoe added a commit that referenced this issue Oct 7, 2015
@krakjoe
Copy link
Owner

krakjoe commented Oct 7, 2015

Thanks for the report ;)

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

No branches or pull requests

2 participants