|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72528 Composer autoload not working on child threads
Submitted: 2016-06-30 17:46 UTC Modified: 2021-02-03 12:36 UTC
Avg. Score:4.5 ± 0.8
Reproduced:15 of 15 (100.0%)
Same Version:6 (40.0%)
Same OS:5 (33.3%)
From: tales dot augusto dot santos at gmail dot com Assigned: cmb (profile)
Status: Wont fix Package: pthreads (PECL)
PHP Version: 5.6.23 OS: Ubuntu 14.04.4 LTS
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: tales dot augusto dot santos at gmail dot com
New email:
PHP Version: OS:


 [2016-06-30 17:46 UTC] tales dot augusto dot santos at gmail dot com
I'm starting a project that uses pthreads to do jobs in parallel. The method \Thread::run is executed in a new context and don't share the autoload previously included at very begining of the script. The solution for that is to require vendor/autoload.php inside that method and the thread can make use of composer autoloader normally. I'm using PHP5.6 with Pthreads 2.0.10 and for some reason the composer can't load the classes needed in the \Thread::runcontext. Inspecting the file vendor/composer/autoload_real.php I realize that composer tries to load the configuration from vendor/composer/autoload_static.php file if the PHP_VERSION_ID is greather than 50600 and HHVM_VERSION constant is not defined. Forcing false to this verification the composer will load the configuration from the autoload_[namespaces|psr4|classmap].php files normally and everything works like a charm. 

This issue already was reported to composer team which tell me to report to pthread maintainers.

Test script:
class MyThread extends \Thread
    public function run()
        register_shutdown_function(function () {
        require 'vendor/autoload.php';
        $obj = new My\Namespace\Class;

// sample.php
require 'vendor/autoload.php';

$thread = new MyThread;
$thread->start() && $thread->join();


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-04 17:22 UTC] tales dot augusto dot santos at gmail dot com
Discussing with members of Composer project, we realize that this problem is related with static class members inside threads. A working demo that reproduce this issue can be found here
 [2021-02-03 12:36 UTC]
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: cmb
 [2021-02-03 12:36 UTC]
The maintainer of PECL/pthreads has ceased its developement for
good reasons[1].  Consider to use PECL/parallel[2] instead.

[1] <>
[2] <>
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 23 04:01:29 2024 UTC