Skip to content

parallel: SIGTERM feeding back into phpstan exit callbacks #2993

@dktapps

Description

@dktapps

Bug report

https://github.com/phpstan/phpstan-src/blob/master/src/Parallel/ParallelAnalyser.php#L146

This is forcibly terminating the process while it may still be working during the loop. This causes some errors detected by child processes to not be reported.

I don't know exactly how to reproduce this problem, but it happens 90% of the time on an aarch64 mobile device with 8 cores (don't judge pls).

SIGTERM exit codes are reported to the react process exit hook - signals which were sent by PHPStan itself.

The most obvious solution seems to be to not forcibly terminate the process, but just close STDIN, so that the child process loop will break, but still report back the final errors that it found.

-- ---------------------------------------------------------
     Error
 -- ---------------------------------------------------------
     Child process error (exit code 143):
     Child process error (exit code 143):
     Child process error (exit code 143):
     Child process error (exit code 143):
     Child process error (exit code 143):
     Child process error (exit code 143):
     Child process error (exit code 143):
     Child process error (exit code 143):
 -- ---------------------------------------------------------

Removing this call seems to make my problem go away locally: https://github.com/phpstan/phpstan-src/blob/master/src/Parallel/Process.php#L130
However I don't know if this may have side effects, or even if it fully works.

Code snippet that reproduces the problem

I don't have a reproducing sample because it happens in a large project and I can't seem to pin it down; besides, it seems to be platform dependent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions