Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Process] Infinite waiting for the dead process #31548

Closed
mshavliuk opened this issue May 19, 2019 · 1 comment
Closed

[Process] Infinite waiting for the dead process #31548

mshavliuk opened this issue May 19, 2019 · 1 comment

Comments

@mshavliuk
Copy link

mshavliuk commented May 19, 2019

Symfony version(s) affected: 4.2.8

Description
Symfony\Component\Process\Process::wait() function can leads to infinite loop in some cases.

How to reproduce

$process = new Process(['someScript.php']);
$process->setTimeout(1);
$process->start();
$process->signal(SIGSTOP);
$process->wait();

The infinite loop occur in while-cycle in 'wait' function:

while ($this->isRunning()) {
    usleep(1000);
}

I've created a repo to easily reproduce this bug:
https://github.com/mshavliuk/SymfonyProcessIssue
It is enough to run showIssue.sh script to run some php code in docker, or, if you have some php environment you can just run php Issue.php after install all packages (which is only symfony/process) and pcntl-ext.

Possible Solution
I will create a pull request with fixes, related with this bug. I hope I will find some solution to create simple and reliable unit-test to reproduce this bug, but It can be very difficult.

@mshavliuk mshavliuk changed the title Infinite waiting for the dead process [Process] Infinite waiting for the dead process May 19, 2019
mshavliuk pushed a commit to mshavliuk/symfony that referenced this issue May 21, 2019
mshavliuk pushed a commit to mshavliuk/symfony that referenced this issue May 21, 2019
mshavliuk pushed a commit to mshavliuk/symfony that referenced this issue May 21, 2019
mshavliuk pushed a commit to mshavliuk/symfony that referenced this issue May 21, 2019
@covobo
Copy link

covobo commented May 22, 2019

I've got the same but with phunitbridge + jms-job-queue.

nicolas-grekas added a commit that referenced this issue May 22, 2019
…iuk)

This PR was squashed before being merged into the 3.4 branch (closes #31568).

Discussion
----------

[Process] Fix infinite waiting for stopped process

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #31548
| License       | MIT

### Description
Add a regression test `Symfony\Component\Process\Tests\ProcessTest:testWaitStoppedDeadProcess` to reproduce the related bug #31548 . It consists of one file `ErrorProcessInitiator.php`, which executes as another process because otherwise if `Process::wait()` goes in an infinite loop (which is test checks) it will be impossible to handle it and stop test correctly.

The second commit contains bug fix, which is only `$this->checkTimeout();` call, that prevents infinite loop.

Commits
-------

6b9ee1e [Process] Fix infinite waiting for stopped process
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants