|  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
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 — but make sure to vote on the bug!
Your email address:
Solve the problem:
37 - 3 = ?
Subscribe to this entry?

 [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: Tue Jun 18 22:01:29 2024 UTC