php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66045 pthreads + spidermonkey cause php crash
Submitted: 2013-11-07 12:23 UTC Modified: 2014-09-26 06:56 UTC
Votes:4
Avg. Score:4.0 ± 1.0
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: vadim at unvsoft dot com Assigned:
Status: Not a bug Package: pthreads (PECL)
PHP Version: 5.5.5 OS: windows 8
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: vadim at unvsoft dot com
New email:
PHP Version: OS:

 

 [2013-11-07 12:23 UTC] vadim at unvsoft dot com
Description:
------------
OS: win8 PHP 5.5.5 pthread 0.45 spidermonkey 1.0.0

when thread finish work php process dies without any messages. If i disable spidermonkey extension all works fine.
 

Test script:
---------------
class MyThread extends Thread {
    private $name;
    function __construct($name) {
        $this->name = $name;
    }
    function run() {
        $res = pow(mt_rand(), mt_rand());
        printf("Thread: %s (%s)\n", $this->name, uniqid());
        flush();
        sleep(1);
    }
}
$threads_max = 10;
$threads = array();
for ($i = 0; $i < $threads_max; $i++) {
    printf("Creating thread: %s\n", $i);
    $threads[$i] = new MyThread("Thread " . $i);
}
foreach ($threads as $thread) $thread->start();

Expected result:
----------------
normal finish of script

Actual result:
--------------
message from windows that script died

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-09-26 06:56 UTC] krakjoe@php.net
-Status: Open +Status: Not a bug
 [2014-09-26 06:56 UTC] krakjoe@php.net
Your threads are not being joined, zend is attempting to destroy them while they are still executing:

class MyThread extends Thread {
    private $name;
    function __construct($name) {
        $this->name = $name;
    }
    function run() {
        $res = pow(mt_rand(), mt_rand());
        printf("Thread: %s (%s)\n", $this->name, uniqid());
        flush();
        sleep(1);
    }
}
$threads_max = 10;
$threads = array();
for ($i = 0; $i < $threads_max; $i++) {
    printf("Creating thread: %s\n", $i);
    $threads[$i] = new MyThread("Thread " . $i);
}
foreach ($threads as $thread) $thread->start();
foreach ($threads as $thread) $thread->join();

sleep() is not intended for use in multi-threaded applications, it is intended to make processes sleep, use usleep if you must have threads sleep, or else use synchronization facilities provided.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 10:01:22 2019 UTC