Closed micahstairs closed 4 years ago
We have a bunch of reports of divergent behavior between PhantomJS run under a terminal and run under PHP shell_exec. We haven't been able to pin any of them down, probably because of differences in PHP configuration. Yours is nice and simple, so would you mind doing some experiments for us?
<?php shell_exec('./phantomjs hello.js < /dev/null 2>&1'); ?>
crash?./phantomjs hello.js 2>&1 | cat
crash?<?php echo exec('tty') ?>
print?<?php passthru('lsof -p $$')?>
print?<?php phpinfo()?>
print?We may have more experiments for you to try based on the results of this.
Great, thanks for your prompt reply! I can definitely work with you to narrow this down.
not a tty
.NOTE: To get the output of running the PHP, I am uploading it to my website and accessing the PHP file from my browser. Let me know if you want me to do this a different way.
Thanks. (That was plenty of the phpinfo
output.) Next experiment. Make sure gdb
and gcc
are installed on your server. Then compile this program on your server: notty-gdb.c using e.g.
$ gcc -g -O2 -std=c99 notty-gdb.c -o notty-gdb
and run it like this:
$ ./notty-gdb /path/to/phantomjs /path/to/hello.js
You will get a (gdb)
prompt. Type signal SIGCONT
and hit return. There will be a bunch of output, and then either something like [Inferior 1 (process NNNN) exited normally]
or something like Program received signal SIGSEGV, Segmentation fault
. If it's the first, type q
to exit the debugger, then cat phantomjs.out
. If it's the second, type bt
to get a backtrace (hopefully with symbols this time) and then q
and cat phantomjs.out
. Either way, tell us what happened.
(You may have to rename the C source file after you download it. Sorry; Github is still being stupid about attachments to bug reports.)
I am afraid I do not have access to gcc.. https://support.ehost.com/articles/hosting-guide/hardware-software/compatible-technologies
That's very unfortunate; I do not know how to write that program in any other language (it does arcane terminal-related stuff that isn't possible in any high-level language I know).
Although ... what happens if you do
$ ssh yourserver /server/path/to/phantomjs /server/path/to/hello.js
or
$ ssh yourserver /bin/sh -c 'exec /server/path/to/phantomjs /server/path/to/hello.js < /dev/null'
from your local machine?
Both of those commands output: Hello, world!
Same problem on hostgator shared server. Maybe I can add some info.
If I run via ssh "php index.php" that contains <?php echo shell_exec('./phantomjs hello.js 2>&1'); ?> I still get the "hello world".
Something is broken in apache?
Please let me know if I can contribute
Due to our very limited maintenance capacity, we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed (see #15395 for more details). In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!
Running this PHP from my server
<?php shell_exec('./phantomjs hello.js 2>&1'); ?>
gives:Running from the terminal (by SSHing into the server)
./phantomjs hello.js
does not crash and gives the expected output:Hello, world!
.Contents of hello.js: