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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
44 - 29 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 23:01:29 2024 UTC