10000 symfony/process returns empty outputs on IIS · Issue #24924 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

symfony/process returns empty outputs on IIS #24924

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

Closed
Rudloff opened this issue Nov 11, 2017 · 17 comments
Closed

symfony/process returns empty outputs on IIS #24924

Rudloff opened this issue Nov 11, 2017 · 17 comments

Comments

@Rudloff
Copy link
Rudloff commented Nov 11, 2017
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.3.11

Hello,
I'm using PHP 7.1 on IIS 7.5 and symfony/process always returns an empty output.

Here is a test case:

<?php
use Symfony\Component\Process\Process;

require_once __DIR__.'/vendor/autoload.php';

//This returns an output
var_dump(shell_exec('dir'));

$process = new Process('dir');
$process->mustRun();
//These return empty strings
var_dump(
    $process->getOutput(),
    $process->getErrorOutput()
);

What's strange is that it works when calling PHP (same binary) from the commandline.
And of course the same code works fine on my Linux/Apache server.

I tested various other commands (cd, Python.exe) and I always get the same empty result.

mustRun() does throw an exception if the command does not exist:

PHP Fatal error:  Uncaught Symfony\Component\Process\Exception\ProcessFailedException: The command "foobar" failed.

Exit Code: 1(General error)

Working directory: C:\inetpub\wwwroot

Output:
================


Error Output:
================
 in C:\inetpub\wwwroot\vendor\symfony\process\Process.php:241
Stack trace:
#0 C:\inetpub\wwwroot\test.php(11): Symfony\Component\Process\Process->mustRun()
#1 {main}
  thrown in C:\inetpub\wwwroot\vendor\symfony\process\Process.php on line 241

Edit: I also tried configuring IIS to use another PHP binary (installed with Chocolatey) and I get the same issue, so I guess it is linked to IIS itself.

@Simperfit
Copy link
Contributor

Status: Needs Review

@Simperfit
Copy link
Contributor

Could you do the following, so we could get a reproducer ?

  • Fork the Symfony Standard Edition or using flex
  • Do the minimum modification to reproduce the bug
  • Post the link in here

In case you need some help you can read this blog post : https://symfony.com/doc/current/contributing/code/reproducer.html

@Rudloff
Copy link
Author
Rudloff commented Nov 12, 2017

Here is a simple diff that reproduces the issue on IIS: Rudloff/symfony-standard@83c49b2

(I can also confirm it does not reproduce when using Symfony's own server:run.)

@xabbuh
Copy link
Member
xabbuh commented Nov 13, 2017

Maybe related to #18503?

@maykino
Copy link
maykino commented Nov 18, 2017

I have the same issue in two different environments. Both run apache.

@nicolas-grekas
Copy link
Member

Oh, I know the reason: PHP on Windows Apache or IIS is threaded, but Process uses getenv() which is not thread safe. Dunno how to fix that. Maybe some thread locking could be used? I don't have any specific more idea in mind..

@nicolas-grekas nicolas-grekas self-assigned this Nov 19, 2017
@legionmaster
Copy link

Running Non-Thread Safe PHP 7.1.12 64bit via FastCGI with IIS 7.5 and Symfony 3.3.13, i do get an output as expected.

@Rudloff
Copy link
Author
Rudloff commented Dec 9, 2017

Is there is no easy fix for this, would it be possible to throw an exception that explains that PHP needs to be non-thread safe?
I find the current behavior very confusing.

@nicolas-grekas
Copy link
Member

Fixed in #25417

fabpot added a commit that referenced this issue Dec 11, 2017
…las-grekas)

This PR was merged into the 3.3 branch.

Discussion
----------

[Process] Dont rely on putenv(), it fails on ZTS PHP

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #24924
| License       | MIT
| Doc PR        | -

`putenv()` is not thread safe, but ZTS is PHP defaults on Windows.

Commits
-------

ef632ec [Process] Dont rely on putenv(), it fails on ZTS PHP
@fabpot fabpot closed this as completed Dec 11, 2017
@Rudloff
Copy link
Author
Rudloff commented Dec 15, 2017

Unfortunately, I can still reproduce the same issue with Symfony 3.4.2.

@rafayexalter
Copy link

I'm getting this same 'empty outputs on IIS' issue...

@Rudloff
Copy link
Author
Rudloff commented Jan 25, 2018

I can still reproduce with Symfony 3.4.3 😞

@soltmar
Copy link
soltmar commented Mar 22, 2018

On Azure (with IIS) running Process fails completely for me with message

The page cannot be displayed because an internal server error has occurred.

Completely nothing in Azure and PHP logs.

@ManuDoni
Copy link
ManuDoni commented Mar 7, 2019

Are there news on this? I'm facing the same problem with Symfony 3.4.23

@carsonbot
Copy link

Hey, thanks for your report!
There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?

@Rudloff
Copy link
Author
Rudloff commented Dec 19, 2020

I don't have access to IIS anymore, so I can not try to reproduce again.

@carsonbot carsonbot removed the Stalled label Dec 19, 2020
@Nyholm
Copy link
Member
Nyholm commented Dec 19, 2020

Since @Rudloff cannot reproduce it anymore and the issue relates to an old version of Symfony, then I suggest closing the issue.

If someone still are facing this bug, then feel free to create a new issue.

@Nyholm Nyholm closed this as completed Dec 19, 2020
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

0