brainpicture / hashlib

lib for node which makes hashes
nodejs.ru
165 stars 35 forks source link

Segmentation faults when compiled against Node w/ non-bundled libeio #5

Closed mojodna closed 13 years ago

mojodna commented 14 years ago

This was built against a Node package from Debian's experimental apt repo (hence the nodejs instead of node). That binary links against external libev and libeio libs, rather than the ones that are bundled with node.

(gdb) run ./test.js
Starting program: /usr/bin/nodejs ./test.js
[Thread debugging using libthread_db enabled]
test 1 PASSED
test 2 PASSED
test 3 PASSED
test 4 PASSED
test 5 PASSED
test 6 PASSED
test 7 PASSED
test 8 PASSED
test 9 PASSED
[New Thread 0xb569db70 (LWP 31166)]

Program received signal SIGSEGV, Segmentation fault.
0xb5756454 in open_cb (req=0x81824b0) at ../hashlib.cc:346
346       fd->fd = EIO_RESULT (req);
brainpicture commented 13 years ago

This is function md5_file. What node version are you use (node -v)

kapouer commented 13 years ago

0.2.5 (the debian version, compiled with shared v8, ev, cares). The above report states wrongly "external libeio" : it is not the case.

At the line of the crash, i get an interesting bug :

(gdb) p {eio_req}req
$3 = {next = 0x0, result = 7, offs = 0, size = 0, ptr1 = 0x0, 
  ptr2 = 0x81824e8, nv1 = 0, nv2 = 0, type = 0, int1 = 1, int2 = 0, 
  int3 = 511, errorno = 0, flags = 0 '\000', pri = 0 '\000', data = 0x402, 
  finish = 0x8182418, destroy = 0xb575a3e0 <open_cb(eio_req*)>, 
  feed = 0x8087d60 <eio_api_destroy>, grp = 0x0, grp_prev = 0x0, 
  grp_next = 0x0, grp_first = 0x0}

where you can see memory is offset by 4 bytes. Hence req->data points to an invalid memory address.

mojodna commented 13 years ago

kapouer, thanks for correcting me and for providing additional info.

mojodna commented 13 years ago

This sounds related:

http://groups.google.com/group/nodejs-dev/browse_thread/thread/6faed759c8c1e792

As Roman Shtylman pointed 1, binary addons should be linked with - lev flag in this case. i think this must be handled by node-waf without any changes in wscript. So, how to determine in wscript that Node was compiled with the --use- shared-libev or --use-shared-libeio flag? If this isn't possible now, should we add support for this in node_addon.py?

kapouer commented 13 years ago

A quick test does not solve the issue (as expected : the segfault is not about unresolved symbol).

mojodna commented 13 years ago

I think this works with Chris Lea's packages now.

kapouer commented 13 years ago

Tests segfaults, but somewhere else (#24), so i guess that eio issue is solved.