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

using __CLASS__ and Thread::start() in a trait causes crash #464

Closed
cottton opened this issue Jul 31, 2015 · 2 comments
Closed

using __CLASS__ and Thread::start() in a trait causes crash #464

cottton opened this issue Jul 31, 2015 · 2 comments

Comments

@cottton
Copy link

cottton commented Jul 31, 2015

works if not using __CLASS__ in trait:

trait aTrait
{
    public function aTrait()
    {
        echo __FUNCTION__ . PHP_EOL;    // aTrait           -- OK
        echo __METHOD__ . PHP_EOL;      // aTrait::aTrait   -- OK
        #echo __CLASS__ . PHP_EOL;     
        $thread = new Thread();         //                  -- OK
        $thread->start();               //                  -- OK
        sleep(3);
    }
}
class A
{
    use aTrait;
}
$A = new A();
$A->aTrait();

crashes if using __CLASS__ in the same script:
(no matter if echo __CLASS___ or $a = __CLASS__)

trait aTrait
{
    public function aTrait()
    {
        echo __FUNCTION__ . PHP_EOL;    // aTrait           -- OK
        echo __METHOD__ . PHP_EOL;      // aTrait::aTrait   -- OK
        echo __CLASS__ . PHP_EOL;       // A                -- OK
        $thread = new Thread();         //                  -- OK
        $thread->start();               //                  -- crash immediately
        sleep(3);
    }
}
class A
{
    use aTrait;
}
$A = new A();
$A->aTrait();

First i thought its because the ref to the created Thread gets lost on leaving the trait.
But this example also crashes:

trait aTrait
{
    public function aTrait($thread)
    {
        echo __FUNCTION__ . PHP_EOL;    // aTrait           -- OK
        echo __METHOD__ . PHP_EOL;      // aTrait::aTrait   -- OK
        echo __CLASS__ . PHP_EOL;       // A                -- OK
        $thread->start();               //                  -- crash
        sleep(3);
    }
}
class A
{
    use aTrait;
}
$A = new A();
$thread = new Thread();
$A->aTrait($thread);
@krakjoe
Copy link
Owner

krakjoe commented Aug 20, 2015

I'm not able to reproduce, can you attach valgrind output please, and more detailed version and OS information.

@krakjoe
Copy link
Owner

krakjoe commented Aug 24, 2015

If the bug still exists in seven (I can't reproduce it), please open a new report ... ;)

@krakjoe krakjoe closed this as completed Aug 24, 2015
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