php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64013 CLI crashed
Submitted: 2013-01-17 17:46 UTC Modified: 2013-01-18 19:40 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: neu dot markus at web dot de Assigned: krakjoe (profile)
Status: Closed Package: pthreads (PECL)
PHP Version: 5.4.11 OS: Windows 7 64bit
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: neu dot markus at web dot de
New email:
PHP Version: OS:

 

 [2013-01-17 17:46 UTC] neu dot markus at web dot de
Description:
------------
Hello,

I'm using PHP 5.4.10 ts, 5.4.11 ts and 5.5Alpha1 ts.
I run PHP in CLI mode. (D:\localhost\php\php.exe -S 0.0.0.0:80 -t 
D:/localhost/htdocs -e -a)


Debugging: php5ts.dll!5fa2eb3389

Test script:
---------------
<?php
require_once("./function.php");
require_once("./libs/Smarty.class.php"); // http://www.smarty.net/

$data = "test";

$func = 1;

$smarty = new Smarty();
$smarty->assign('test', 	$data);

print_r(MyThreadFunc($func, $smarty));

?>

<?php
error_reporting(E_ALL);
class MyThread extends Thread
{
    public $func;
    public $data;
    public $res;
    public function __construct($func, $data)
    {
        $this->func = $func;
        $this->data = $data;
    }

    public function run()
    {
        //printf("%s is Thread #%lu\n", __CLASS__, $this->getThreadId());
        if($this->func == 1)
        {
            $this->res = func1($this->data);
        }
        elseif($this->func == 2)
        {
            $this->res = func2($this->data);
        }
        elseif($this->func == 3)
        {
            $this->res = func3($this->data);
        }
        elseif($this->func == 4)
        {
            $this->res = func4($this->data);
        }
        unset($this->data);

    }

}


function MyThreadFunc($func, $data)
{
    $t = microtime(true);
    $g = new MyThread($func, $data);
    /* starting synchronized */
    if($g->start())
    {
        printf("Request took %f seconds to start ", microtime(true)-$t);
        
        //while($g->isRunning())
        //{
        //    echo ".";
        //    usleep(100);
        //}
        if ($g->join())
        {
            printf(" and %f seconds to finish\n", microtime(true)-$t);
            return $g->res;
        }
        else
        {
            printf(" and %f seconds to failed\n", microtime(true)-$t);
        }
    }
    unset($data);
}


function func1($data)
{
	return $smarty->fetch('test.tpl');
}
function func2($data)
{
	return $data;
}
function func3($data)
{
	return $data;
}
function func4($data)
{
	return $data;
}

?>

Expected result:
----------------
The template test.tpl should displayed

Actual result:
--------------
Allow obj in Threads or build an error report

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-01-18 19:01 UTC] krakjoe@php.net
http://pthreads.org/snapshots/5.4/99f3d418dff4a8bc5bd8ed7f92ca596088be5590.zip

Please try this snapshot, test it with php-5.4 only, I've no snapshots available 
for 5.5 yet.

Objects are supported in Threads.

If the errors persist, please provide a script that exhibits the problem that is 
self contained.
 [2013-01-18 19:40 UTC] krakjoe@php.net
I have noticed an error in pthreads, which is fixed in the latest code in git, 
no snapshot yet I'll roll one tomorrow, I cannot release the code in git, I have 
a few minor bugs to squish first.

I have also noticed some errors in your logic, func1 has no $smarty defined. The 
only place you can share variables is the object context. Please see the 
documentation and examples included in the release for correct usage, and the 
PHP manual for an explanation of the environment and it's functionalities.

Thanks for your report.
 [2013-01-18 19:40 UTC] krakjoe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: krakjoe
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:21 2019 UTC