进程派生期间 PHAR 内部损坏(crc32 不匹配)

mis*_*ion 8 php linux fork phar

我是ko-worker库的开发。我添加了 phar 可执行文件作为守护程序应用程序的功能。并发现 phar 和进程分叉 undex linux 的奇怪行为。每次主进程分叉超过 1 个孩子时,我都会遇到这样的错误

include(phar:///opt/www/worker.phar/vendor/path/to/file.php): 
failed to open stream: phar error: internal corruption of phar    

"/opt/www/worker.phar" (crc32 mismatch on file "vendor/path/to/file.php")
in `phar:///opt/www/worker.phar/vendor/composer/ClassLoader.php` line 412
Run Code Online (Sandbox Code Playgroud)

phar的存根(这里原始存根)看起来像

#!/usr/bin/env php
<?php
     Phar::mapPhar('worker.phar');
     require_once 'phar://worker.phar/vendor/autoload.php';

     //Execute next going fork code more then one 1 time
     ...
     $pid = pcntl_fork();
     if ($pid == -1) {
         die('could not fork');
     } else if ($pid) {
        // we are the parent
        ...
     } else {
        // we are the child
        ...
        exit(1);
     }

     __HALT_COMPILER();
Run Code Online (Sandbox Code Playgroud)

我不使用cache_list。仅当 phar 使用 GZ 或 BZ2 压缩时才会发生这种情况。未经压缩的 Phar 文件不会重现此错误。是否有任何解决方法,或者可能是有关限制压缩 phars 和分叉进程的一些信息?

Mvo*_*sek 2

似乎是 PHP 问题,请在https://bugs.php.net/上报告为错误,并提供重现步骤。