Debugging a failed page.open call / status == "fail"

1,774 views
Skip to first unread message

Jörn Zaefferer

unread,
Aug 15, 2011, 4:17:37 PM8/15/11
to phantomjs
In trying to debug why my script fails to open a QUnit-testsuite, I'm
sorely missing any helpful error messages. The open-callback is
called, with a status of "fail". At that point, "onLoadStarted" was
called twice. Afterwards, phantomjs crashes, output nothing but
"Segmentation fault".

This is the script I'm using: https://gist.github.com/75dd5affcd1e7f106517

It works (almost) perfectly against the QUnit testsuite, so afaik the
script is not at fault, but something in the application's testsuite,
which I can't share in full. Without any hint of phantomjs at what the
issue might be, I'm stuck with using PhantomJS 1.1, which works mostly
fine.

I've looked for command line arguments or error callbacks in the API
and came up with nothing. So, what else is there?

James Roe

unread,
Aug 15, 2011, 6:07:28 PM8/15/11
to phantomjs
How're you calling your script on the command-line?

On Aug 15, 1:17 pm, Jörn Zaefferer <joern.zaeffe...@googlemail.com>
wrote:

James Roe

unread,
Aug 15, 2011, 6:21:45 PM8/15/11
to phantomjs
Scratch what I said earlier.

On Aug 15, 1:17 pm, Jörn Zaefferer <joern.zaeffe...@googlemail.com>
wrote:
> Afterwards, phantomjs crashes, output nothing but
> "Segmentation fault".
This might be related to phantom.exit() crashing on exit, which has
already been fixed in master, in commit a2aed006 and 5acaa6b4
(represented in issues #136, #148 and #149).
https://github.com/ariya/phantomjs/commit/a2aed0064c852ba9bc57de421b1294565da6e5d2
https://github.com/ariya/phantomjs/commit/5acaa6b42d510f529ea77507f678b114bac73d9c

Not sure about the others, but hopefully that helps you out some.

Jörn Zaefferer

unread,
Aug 16, 2011, 4:58:33 AM8/16/11
to phantomjs
I've been building phantomjs myself based on master, so, no, that
doesn't really help.

On Aug 16, 12:21 am, James Roe <roejame...@hotmail.com> wrote:
> Scratch what I said earlier.
>
> On Aug 15, 1:17 pm, Jörn Zaefferer <joern.zaeffe...@googlemail.com>
> wrote:> Afterwards, phantomjs crashes, output nothing but
> > "Segmentation fault".
>
> This might be related to phantom.exit() crashing on exit, which has
> already been fixed in master, in commit a2aed006 and 5acaa6b4
> (represented in issues #136, #148 and #149).https://github.com/ariya/phantomjs/commit/a2aed0064c852ba9bc57de421b1...https://github.com/ariya/phantomjs/commit/5acaa6b42d510f529ea77507f67...

Ariya Hidayat

unread,
Aug 16, 2011, 8:42:04 AM8/16/11
to phan...@googlegroups.com
> I've been building phantomjs myself based on master, so, no, that
> doesn't really help.

It still baffles me that those crashes does still exist.

The issue with onLoadStarted triggered twice is definitely a hint,
though as of now I can't think of any scenarios where it shall occur
(beside redirection, which I don't think you have).

Jörn, any chance to build in debug mode and post the stack trace?

Thanks!

Regards,

--
Ariya Hidayat, http://ariya.ofilabs.com

Jörn Zaefferer

unread,
Aug 16, 2011, 11:02:05 AM8/16/11
to phantomjs
There's a debug mode? Why isn't that mentioned anywhere? I'd be happy
to try that, just let me know how (and consider putting that on the
page with the build instrctuons).

Ariya Hidayat

unread,
Aug 16, 2011, 12:53:19 PM8/16/11
to phan...@googlegroups.com
> There's a debug mode? Why isn't that mentioned anywhere? I'd be happy
> to try that, just let me know how (and consider putting that on the
> page with the build instrctuons).

It's the standard C++ debug mode (not JavaScript). Since we use qmake,
the easiest way is:

qmake CONFIG+=DEBUG
make

Then you should be able to launch the executable with gdb and capture
the stack trace when it crashes.

Thank you!

--
Ariya Hidayat, Passionate Technologist
http://ariya.ofilabs.com

Jörn Zaefferer

unread,
Aug 18, 2011, 5:27:18 AM8/18/11
to phantomjs
After digging around a bit to get familiar with gdb, I got this:
https://gist.github.com/e0ad2c8dd39c775d97a3

Hope that helps figuring out why its crashing, but I'm still
completely lost on why its failing to load in the first place. With
status="fail" being the only feedback I get, debugging this is
hellish.

Alessandro Portale

unread,
Aug 18, 2011, 6:48:12 AM8/18/11
to phan...@googlegroups.com
It seems that the Qt version you have has no debug symbol files
installed at the expected location. Did you configure and build Qt
yourself?

I tried to get the stack trace but I do not get far enough to
reproduce the crash. When calling your script from
https://gist.github.com/75dd5affcd1e7f106517 once without and one with
parameter, the script just exits with error messages:

aportale$ phantomjs test.js
load started
Unable to access network: fail

aportale$ phantomjs test.js http://www.google.com
load started
ReferenceError: Can't find variable: QUnit

Do you have a self-contained script to reproduce the crash?

Jörn Zaefferer

unread,
Aug 19, 2011, 5:32:49 AM8/19/11
to phantomjs


On Aug 18, 12:48 pm, Alessandro Portale
<alessandro.port...@googlemail.com> wrote:
> It seems that the Qt version you have has no debug symbol files
> installed at the expected location. Did you configure and build Qt
> yourself?

No I didn't. So far I followed the advice of installing Qt, not
building manually.

> I tried to get the stack trace but I do not get far enough to
> reproduce the crash. When calling your script fromhttps://gist.github.com/75dd5affcd1e7f106517once without and one with
> parameter, the script just exits with error messages:
>
> aportale$ phantomjs test.js
> load started
> Unable to access network: fail

In this case its the missing parameter, in my case its something else,
but I have absolutely no idea what it may be. I need something to
debug that page.open call.

>
> aportale$ phantomjs test.jshttp://www.google.com
> load started
> ReferenceError: Can't find variable: QUnit
>
> Do you have a self-contained script to reproduce the crash?

I don't, it happens only for this bigger application-specific
testsuite that I can't share. And I'm stuck with that big chunk as I
have no idea what actual component might be responsible for the crash.
As long as it doesn't correctly load the suite in the first place, the
crash isn't even my biggest problem.

Any other ideas how to debug that loading step?

Ariya Hidayat

unread,
Aug 19, 2011, 3:44:36 PM8/19/11
to phan...@googlegroups.com
> I don't, it happens only for this bigger application-specific
> testsuite that I can't share. And I'm stuck with that big chunk as I
> have no idea what actual component might be responsible for the crash.
> As long as it doesn't correctly load the suite in the first place, the
> crash isn't even my biggest problem.
>
> Any other ideas how to debug that loading step?

Could you see if any resource is loaded at all? Check the netsniff
example to see how to dump some network traffic info.

Ariya Hidayat

unread,
Sep 17, 2011, 2:24:48 PM9/17/11
to phan...@googlegroups.com
I'm willing to invest some time to solve this issue. I saw that it is
also mentioned in
http://backstage.soundcloud.com/2011/09/mobile-unit-testing/.

However, we need some material to work with. Ideally, the script that
can reproduce the problem. Preferably of course the reduced test case
which consistently shows the problem.

Another long shots:

- Try the 1.3 branch. A lot of work has been put to prevent many types
of crashes.

- Compile statically. There is deploy/build-mac.sh for Mac OS X and I
still need to adapt it to work on Linux
(http://code.google.com/p/phantomjs/issues/detail?id=197). Help is
welcomed!

- Look at netlog.js and try to live-dump the network request/response.
This should give an idea of the progress of the loading

Looking forward to seeing this problem resolved.


Thanks!

Best regards,

Reply all
Reply to author
Forward
0 new messages