Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

2.1.1 crashes when being invoked from webserver using php 1.9.7 does not #14008

Closed
orthosie opened this issue Feb 15, 2016 · 9 comments
Closed

Comments

@orthosie
Copy link

Ubuntu Linux 3.2.61-grsec-modsign #1 SMP x86_64 GNU/Linux , Apache

I have been using phantomjs 1.9.7 to take screen shots through php. I am trying to upgrade to 2.1.1 and the same command using 2.1.1 is not working. The error output says phantomjs crashed. This is what is being printed to the error log.

PhantomJS has crashed. Please read the bug reporting guide at
http://phantomjs.org/bug-reporting.html and file a bug report.

The following is the php. Both 1.9.7 and 2.1.1 works fine from command line without php or when the following php is being invoked from the command line. But 2.1.1 crashes when invoked from a webserver while accessing via url.

array("pipe", "r"), // stdin is a pipe that the child will read from 1 => array("pipe", "w"), // stdout is a pipe that the child will write to 2 => array("file", "phantomjs-error-output.txt", "a") // stderr is a file to write to ); proc_close (proc_open ("$cmd19", $dp, $foo)); ?>
@GDmac
Copy link

GDmac commented Feb 18, 2016

if you look at the proc_open example on http://php.net/manual/en/function.proc-open.php it is suggested to close the pipes before proc_close, to prevent a deadlock. What happens if you run the first command manually from the command line?

@zackw
Copy link
Contributor

zackw commented Feb 18, 2016

@orthosie Thank you for your bug report. Unfortunately, we cannot do anything about it without a reduced, self-contained test case. Please read our draft bug reporting guidelines and follow the instructions. If they are unclear, please let us know in the discussion thread on that document.

In this case, it is clear that the problem is related to running PhantomJS under PHP instead of in a terminal, but we also need a minimized version of pageprint.js, and a minimized version of the website https://theysaidso.com. (The website could change at any moment in a way that made the problem disappear.)

@orthosie
Copy link
Author

@GDmac closing the pipes didn't solve the problem. @zackw attaching pageprint.js and also made a special page (which won't change) to reproduce the problem (using the short url for convenience here, but the problem happens regardless whether I use the short url or not).

<?php

error_reporting(E_ALL);

$cmd = "/home/me/toolkits/phantomjs/2.1.1/x86_64/bin/phantomjs  --ignore-ssl-errors=yes --ssl-protocol=any  /home/me/lib/pageprint.js https://goo.gl/MDrfz9 /home/me/YhXV6EStHS_hCmZH061iuQeF.png";

$dp = array(
                      0 => array("pipe", "r"),  // stdin is a pipe that the child will read from
                      1 => array("pipe", "w"),  // stdout is a pipe that the child will write to
                      2 => array("file", "phantomjs-error-output.txt", "a") // stderr is a file to write to
                      );

$fd = proc_open ("$cmd", $dp, $foo);
fclose($foo[0]);
fclose($foo[1]);
proc_close ($fd);
?>

pageprint.js.txt

@GDmac
Copy link

GDmac commented Feb 19, 2016

That page contains some huge assets (5mb image ???). Anyway, as asked, have you tried running the command at the commandline? (your example works ok on phantomjs-2.1.1-macosx)

ps. you can mark php code blocks, makes them easier to read

(code)

@orthosie
Copy link
Author

@GDmac & @zackw thanks for looking into this. @GDmac as mentioned in the initial post this works when invoked from command line (php and just plain shell both works fine). The problem exhibits itself only when called in the webserver context i.e. via url in the browser. Also I have tried with very small image size (200kb) as well and it has the same problem.

Made some progress. Figured out exactly what portion of the page is causing the crash. If the SVG CSS filters in the header is removed this works. I guess 1.9.7 never paid attention to the filters but 2.1.1 does and that is the reason 1.9.7 works here. But what I don't understand is why 2.1.1 should fail only in the webserver context and not in command line shell or command line php context?

@GDmac
Copy link

GDmac commented Feb 20, 2016

i had no problem to run the example on my local apache.
This make the issue point to the server (and/or its config/settings)

@adamdyson
Copy link

I'll be watching this thread, as I am experiencing the exact same problems.

@jshin49
Copy link

jshin49 commented May 11, 2016

I'll second adamdyson as I am experiencing the exact same problem.

Works perfectly fine with 1.9.7, but I have rendering issues with that version.

Crashes with 2.1.1 through php exec calls from server context, but doesn't from command line shell.

@ghost ghost removed 2.1 labels Jan 10, 2018
@stale stale bot added the stale label Dec 25, 2019
@stale
Copy link

stale bot commented Dec 28, 2019

Due to our very limited maintenance capacity (see #14541 for more details), we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed. In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!

@stale stale bot closed this as completed Dec 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants