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

Already on GitHub? Sign in to your account

Always crashes from PHP, Perl, etc. #11999

Closed
dmyshkin opened this Issue Feb 21, 2014 · 6 comments

Comments

Projects
None yet
3 participants

On our CentOS 6.5 system, PhantomJS always crashes when executed with a simple 'hello world' script when executed via PHP or Perl triggered from Apache. If the php or perl script is run from the command line, it works. Note that this problem does NOT happen on our Ubuntu 8.04 machine. We have tried both building from source and the binaries. We are using the 64 bit version. The 32 bit version does not run at all, gives ELF error.

Crash message:
PhantomJS has crashed. Please read the crash reporting guide at https://github.com/ariya/phantomjs/wiki/Crash-Reporting and file a bug report at https://github.com/ariya/phantomjs/issues/new with the crash dump file attached: /tmp/7be7b6c1-232b-ad26-0bdc14c8-692edb4b.dmp

Perl script:

!/usr/bin/perl

print "Content-type:text/html\r\n\r\n";
my $phantomjs = "/var/www/phantomjs /var/www/perl/testphantom.js";
$output = $phantomjs;
print($output);

PHP script:

testphantom.js:
console.log("hello world");
phantom.exit();

After trying to dump the symbols, this happens:
[root@prsgce-1 phantomjs-1.9.7-linux-x86_64-symbols]# ./minidump_stackwalk /tmp/7be7b6c1-232b-ad26-0bdc14c8-692edb4b.dmp .
2014-02-21 00:37:35: minidump_processor.cc:264: INFO: Processing minidump in file /tmp/7be7b6c1-232b-ad26-0bdc14c8-692edb4b.dmp
2014-02-21 00:37:35: minidump.cc:3775: INFO: Minidump opened minidump /tmp/7be7b6c1-232b-ad26-0bdc14c8-692edb4b.dmp
2014-02-21 00:37:35: minidump.cc:4046: ERROR: ReadBytes: read 0/32
2014-02-21 00:37:35: minidump.cc:3794: ERROR: Minidump cannot read header
2014-02-21 00:37:35: minidump_processor.cc:268: ERROR: Minidump /tmp/7be7b6c1-232b-ad26-0bdc14c8-692edb4b.dmp could not be read
2014-02-21 00:37:35: minidump.cc:3747: INFO: Minidump closing minidump

Collaborator

JamesMGreene commented Feb 21, 2014

I'm not overly familiar but I have a leading question: if you exec an external executable from within PHP/Perl/etc., is that child process confined to the memory allocated for the parent script process? If so, I would check to ensure that your Apache config isn't limiting the process (or child processes) to a small chunk of memory. 64-bit Phantom (WebKit) on Linux will attempt to reserve 1 GB of memory right when it starts, IIRC.

So, I have some more information:

  1. I was able to get the 'instant crash' to stop happening from PHP, by setting the httpd_execmem se bool to true.
  2. While the "hello world" script runs fine now, the actual script i'm trying to run (which waits for the page it loads to fire a callback, and then outputs the results), does something even stranger - when you run the script from the command line (not via PHP), it first outputs the "PhantomJS has crashed" message, then immediately outputs the results of the callback (the data), as if it had not crashed.
  3. the actual script (callback watcher) simply hangs when run through PHP, it does not generate any output nor terminates.
  4. all of this works fine on my Ubuntu system, both command line and through PHP, so to answer your question about the memory boxing - if that was the case it wouldn't work on Ubuntu either. Both have a similar Apache configuration.

Here is the actual script i am trying to run (the one that crashes right away from command line then spits out the output)

var page = require('webpage').create();
var system = require('system');
var address = system.args[1];
page.open(address);
page.onCallback = function(data) {
console.log(data.screenshot);
phantom.exit();
};

and the page it's trying to render:

<script> $(function() { convertImgToBase64('http://www.peltrade.com/img/1.jpg', function(base64Img){ if (typeof window.callPhantom === 'function') { window.callPhantom({ screenshot: base64Img }); } }); }); </script>
Collaborator

Vitallium commented Apr 11, 2016

Please upgrade to PhantomJS 2. 1.9.x is no longer supported, and known to have many crasher bugs that are fixed in 2 version.

@Vitallium Vitallium closed this Apr 11, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment