Skip to content

Instantly share code, notes, and snippets.

@ikariiin
Created May 5, 2016 17:32
Show Gist options
  • Save ikariiin/c2175e6b03503aff8731306a20e00252 to your computer and use it in GitHub Desktop.
Save ikariiin/c2175e6b03503aff8731306a20e00252 to your computer and use it in GitHub Desktop.

Reproduction Script

<?php declare(strict_types = 1);
/**
 * Created by PhpStorm.
 * User: gourab
 * Date: 5/5/16
 * Time: 10:28 PM
 * About: Trying to reproduce the result when, trying to unserialize an object
 */

class sampleClass extends Thread {
    private $clousure;

    public function __construct(callable $clousure) {
        $this->clousure = $clousure;
    }

    public function callClousure() {
        $clousure = $this->clousure;
        return $clousure();
    }
}

$clousure = function() : \stdClass {
    $std = new \stdClass();
    $std->value = [10, 87, 655];
    return $std;
};

$simpleObject = new sampleClass($clousure);

class ThreadInstance extends \Thread {
    private $args;

    public function __construct(array $args) {
        $this->args = $args;
    }

    public function run() {
        var_dump(unserialize($this->args));
        echo "IF THIS LINE GETS OUTPUT-ED, I AM STUPID!!";
    }
}

$threadObject = new ThreadInstance([serialize($simpleObject)]);
$threadObject->start();

Output:

/usr/local/bin/php /home/gourab/Desktop/Leloutama/pthreads_test_case.php

Process finished with exit code 0

Details

  • Pthreads version: 3.1.6
  • PHP:
PHP 7.0.3 (cli) (built: Mar  2 2016 22:32:08) ( ZTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
  • OS: Linux Mint 17.3 (not sure about the version number, but the version name is Rosa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment