deanmao / node-chimera

A new kind of headless webkit integration for nodejs; a great alternative to phantomjs.
http://www.deanmao.com/2012/08/13/enter-chimera/
MIT License
847 stars 45 forks source link

Segmentation fault: 11 #28

Open davethegr8 opened 11 years ago

davethegr8 commented 11 years ago

Trying out chimera today, and I'm getting the Seg Fault: 11 error others have reported. I used npm install chimera just a few minutes ago. I tried doing gdb node to run my script, and this is the result:

(gdb) run app.coffee 
Starting program: /usr/local/bin/node app.coffee
Reading symbols for shared libraries ++++................................................................................................................................. done
Using the chimera in lib
Reading symbols for shared libraries warning: Could not find object file "/Users/catch23/current/node-chimera/build/Release/obj.target/chimera/src/top.o" - no debug information available for "top.cc".

warning: Could not find object file "/Users/catch23/current/node-chimera/build/Release/obj.target/chimera/src/cookiejar.o" - no debug information available for "cookiejar.cc".

warning: Could not find object file "/Users/catch23/current/node-chimera/build/Release/obj.target/chimera/src/chimera.o" - no debug information available for "chimera.cc".

warning: Could not find object file "/Users/catch23/current/node-chimera/build/Release/obj.target/chimera/src/browser.o" - no debug information available for "browser.cc".

......... done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000007
0x0000000102d0cee8 in QString::fromLocal8Bit ()

Looks like there are some hardcoded paths for libraries preventing chimera from running (my user is not catch23)?

deanmao commented 11 years ago

The hardcoded paths you see above are not related to the segfault -- those are just locations where the debugging symbols could be if they were needed. If they aren't available, nothing bad will happen. Maybe you can run a gdb trace to see where it died on?

davethegr8 commented 11 years ago

Either that's succeeding where regular gdb isn't... or I'm doing something wrong. I can't seem to figure out the gdb trace usage. For context, here is my program:

var Chimera = require('chimera').Chimera;

var c = new Chimera();

c.perform({
url: "http://www.google.com",
locals: {

},
run: function(callback) {
    callback(null, "success");
},
callback: function(err, result) {
    // capture a screen shot
    c.capture("screenshot.png");
}
});

Chimera is installed in the node_modules folder in the same directory.

vjpr commented 11 years ago

+1 same problem.

vjpr commented 11 years ago

Interesting.

I had the line request = require 'request' in the same file I use Chimera.

Commenting it out fixed the issue.

Seeing as Chimera needs "request": "~2.12.0", it must break with the newer version of request 2.22.

legnaleurc commented 10 years ago

Full stack on Debian Sid amd64

#0  0x00007ffff553991a in QString::fromLocal8Bit (str=0x4 <Address 0x4 out of bounds>, size=size@entry=-1) at tools/qstring.cpp:3960
#1  0x00007ffff55f80e1 in QCoreApplication::arguments () at kernel/qcoreapplication.cpp:2339
#2  0x00007ffff4a0f45a in sm_performSaveYourself (smd=0x902150) at kernel/qapplication_x11.cpp:5754
#3  0x00007ffff4a0fff5 in sm_saveYourselfCallback (smcConn=<optimized out>, clientData=<optimized out>, saveType=<optimized out>, shutdown=<optimized out>, interactStyle=<optimized out>)
    at kernel/qapplication_x11.cpp:5737
#4  0x00007fffed75ad2f in _SmcProcessMessage () from /usr/lib/x86_64-linux-gnu/libSM.so.6
#5  0x00007fffed54c8a6 in IceProcessMessages () from /usr/lib/x86_64-linux-gnu/libICE.so.6
#6  0x00007ffff560a4c8 in QMetaObject::activate (sender=sender@entry=0x905b50, m=m@entry=0x7ffff5959a40 <QSocketNotifier::staticMetaObject>, local_signal_index=local_signal_index@entry=0, 
    argv=argv@entry=0x7fffffffd490) at kernel/qobject.cpp:3547
#7  0x00007ffff5654f2e in QSocketNotifier::activated (this=this@entry=0x905b50, _t1=20) at .moc/release-shared/moc_qsocketnotifier.cpp:102
#8  0x00007ffff56132ab in QSocketNotifier::event (this=0x905b50, e=0x7fffffffd780) at kernel/qsocketnotifier.cpp:316
#9  0x00007ffff499675c in QApplicationPrivate::notify_helper (this=this@entry=0x7e39c0, receiver=receiver@entry=0x905b50, e=e@entry=0x7fffffffd780) at kernel/qapplication.cpp:4567
#10 0x00007ffff499cdd0 in QApplication::notify (this=0x7e3230, receiver=0x905b50, e=0x7fffffffd780) at kernel/qapplication.cpp:4353
#11 0x00007ffff55f633d in QCoreApplication::notifyInternal (this=0x7e3230, receiver=0x905b50, event=event@entry=0x7fffffffd780) at kernel/qcoreapplication.cpp:949
#12 0x00007ffff5624110 in sendEvent (event=0x7fffffffd780, receiver=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:231
#13 socketNotifierSourceDispatch (source=0x7e5190) at kernel/qeventdispatcher_glib.cpp:110
#14 0x00007ffff41cdea6 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#15 0x00007ffff41ce1f8 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#16 0x00007ffff41ce29c in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#17 0x00007ffff56234b5 in QEventDispatcherGlib::processEvents (this=0x7e4e00, flags=...) at kernel/qeventdispatcher_glib.cpp:425
#18 0x00007ffff4a34896 in QGuiEventDispatcherGlib::processEvents (this=<optimized out>, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
#19 0x00007ffff55f9d7f in QCoreApplication::processEvents (flags=...) at kernel/qcoreapplication.cpp:1136
#20 0x00007ffff5964882 in ProcessEvents(v8::Arguments const&) () from /tmp/node_modules/chimera/build/Release/chimera.node
#21 0x00007ffff7440d43 in ?? () from /usr/lib/libv8.so.3.14.5
#22 0x00003c29cf606362 in ?? ()
#23 0x00007fffffffdae0 in ?? ()
#24 0x00003c29cf6062c1 in ?? ()
#25 0x00007fffffffdaa0 in ?? ()
#26 0x00007fffffffdb00 in ?? ()
#27 0x00003c29cf6123f8 in ?? ()
#28 0x00002be18f26bc59 in ?? ()
#29 0x00001bd6fbfdcee1 in ?? ()
#30 0x0000000000000000 in ?? ()

I think this is because you initialized QApplication with:

int argc = 0;
char ** argv = NULL;

So QCoreApplication::arguments() gets invalid strings.

legnaleurc commented 10 years ago

Find out why:

http://stackoverflow.com/questions/12135577/users-arguments-are-empty-with-qcoreapplication-in-mysterious-cases

QApplication takes int& argc as a reference, so it should not be a local variable.

Change int argc to a static or global variable solves this problem.