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

Lost resource. #930

@fridreman

Description

@fridreman

Environment

  • PHP: 7.2.2
  • pthreads: 3.2.1dev

Summary

When assigning another object in the class constructor, the resource is lost.

Reproducing Code

$customSocket = new CustomSocket();
$exampleThread = new ExampleThread($customSocket);

class CustomSocket {
    public $socket;

    public function __construct()
    {
        $this->socket = socket_create(AF_UNIX, SOCK_STREAM, 0);
    }
}

class ExampleThread extends Thread {
    public $localCustomSocket;
    public $localSocket;

    public function __construct(CustomSocket $customSocket)
    {
        var_dump($customSocket);

        $this->localCustomSocket = $customSocket;
        var_dump($this->localCustomSocket);

        $constructorCustomSocket = $customSocket;
        var_dump($constructorCustomSocket);

        $this->localSocket = $customSocket->socket;
        var_dump($this->localSocket);
    }
}

Expected Output

object(CustomSocket)#1 (1) {
  ["socket"]=>
  resource(5) of type (Socket)
}
object(CustomSocket)#3 (1) {
  ["socket"]=>
  resource(5) of type (Socket)
}
object(CustomSocket)#1 (1) {
  ["socket"]=>
  resource(5) of type (Socket)
}
resource(5) of type (Socket)

Actual Output

object(CustomSocket)#1 (1) {
  ["socket"]=>
  resource(5) of type (Socket)
}
object(CustomSocket)#3 (1) {
  ["socket"]=>
  int(0)
}
object(CustomSocket)#1 (1) {
  ["socket"]=>
  resource(5) of type (Socket)
}
resource(5) of type (Socket)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions