Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault with ftp get #46

Closed
johnnypez opened this issue Feb 7, 2016 · 7 comments
Closed

Segfault with ftp get #46

johnnypez opened this issue Feb 7, 2016 · 7 comments

Comments

@johnnypez
Copy link

Hi, I'm just trying to do a simple FTP get and hitting a segfault on Ubuntu 14.04.3 LTS with Node 0.10.40 and libcurl 7.35.0.

It works locally on my macbook (osx 10.10.5 / node 0.10.40 / libcurl 7.43.0)

From poking around other segfault issues reported here, it's clear they are very hard to reproduce.

Here's what I use to trigger the error. The ftp host and credentials have been swapped out for dummy credentials.

var Curl, curl;

Curl = require('node-libcurl').Curl;

curl = new Curl;

curl.setOpt(Curl.option.URL, "ftp://dummyuser:dummypass@inbound.acme.com/feed.csv");

curl.setOpt(Curl.option.VERBOSE, 1);

curl.setOpt(Curl.option.DEBUGFUNCTION, require('./debug')); // returns the debug function from node-libcurl examples

curl.on('end', function() {
  return console.log(arguments, curl.getInfo(Curl.info.SIZE_DOWNLOAD));
});

curl.perform();

Which results in a segfault just as the transfer is about to begin.

Hostname was NOT found in DNS cache

  Trying x.x.x.x...

Connected to inbound.acme.com (x.x.x.x) port 21 (#0)

-- RECEIVING HEADER:
220 Acme LLC

-- SENDING HEADER:
USER dummyuser

-- RECEIVING HEADER:
331 Please specify the password.

-- SENDING HEADER:
PASS dummypass

-- RECEIVING HEADER:
230 Login successful.

-- SENDING HEADER:
PWD

-- RECEIVING HEADER:
257 "/"

Entry path is '/'

-- SENDING HEADER:
PASV

Connect data stream passively

ftp_perform ends with SECONDARY: 0

-- RECEIVING HEADER:
227 Entering Passive Mode (x,x,x,x,159,192).

Hostname was NOT found in DNS cache

  Trying x.x.x.x...

Connecting to x.x.x.x (x.x.x.x) port 40000

PID 14645 received SIGSEGV for address: 0x1c81
/home/dev/workspace/myapp/node_modules/segfault-handler/build/Release/segfault-handler.node(+0x1973)[0x7f0a0c176973]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x10340)[0x7f0a15665340]
/usr/lib/x86_64-linux-gnu/libcurl.so.4(+0x3042c)[0x7f0a14e3a42c]
/usr/lib/x86_64-linux-gnu/libcurl.so.4(+0x30cca)[0x7f0a14e3acca]
/usr/lib/x86_64-linux-gnu/libcurl.so.4(+0x335be)[0x7f0a14e3d5be]
/usr/lib/x86_64-linux-gnu/libcurl.so.4(curl_multi_socket_action+0x17)[0x7f0a14e3d627]
/home/dev/workspace/myapp/node_modules/node-libcurl/lib/binding/node_libcurl.node(_ZN11NodeLibcurl5Multi8OnSocketEP9uv_poll_sii+0x4d)[0x7f0a1508755d]
/home/dev/.nvm/v0.10.40/bin/node(uv__io_poll+0x300)[0x9e5a40]
/home/dev/.nvm/v0.10.40/bin/node(uv_run+0xd8)[0x9d9398]
/home/dev/.nvm/v0.10.40/bin/node(_ZN4node5StartEiPPc+0x16c)[0x9853ec]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7f0a152b1ec5]
/home/dev/.nvm/v0.10.40/bin/node(cos+0x129)[0x5a54a9]

So whatever is going wrong is happening in NodeLibcurl::Multi::OnSocket(uv_poll_s*, int, int) I guess but I'm not sure how to debug any further than that.

Any help anyone could offer would be greatly appreciated. Let me know if I need to provide any more information for context.

@JCMais
Copy link
Owner

JCMais commented Feb 7, 2016

Hi,

what version of node-libcurl are you using?

@johnnypez
Copy link
Author

Hey, sorry I forgot to add that. It's 0.7.0

@johnnypez
Copy link
Author

In case it was anything to do with having an older version of libcurl, I built and installed curl 7.47.1. Then reinstalled node-libcurl 0.7.0 with the --build-from-source flag but still experience the same problem.

@johnnypez
Copy link
Author

Just adding more detail as I poke around.
I added libcurl-dbg package and ran my sample code above through gdb.
At this point though, I'm not sure what I'm looking for.

0x00007ffff672e42c in Curl_hash_pick (h=0xf56a20, key=key@entry=0x7fffffffac08, key_len=key_len@entry=4)
    at hash.c:215
215     hash.c: No such file or directory.
(gdb) bt
#0  0x00007ffff672e42c in Curl_hash_pick (h=0xf56a20, key=key@entry=0x7fffffffac08, key_len=key_len@entry=4)
    at hash.c:215
#1  0x00007ffff672ecca in singlesocket (multi=multi@entry=0xf52180, data=data@entry=0xf73990) at multi.c:1953
#2  0x00007ffff67315be in multi_socket (multi=multi@entry=0xf52180, checkall=checkall@entry=false, s=10,
    ev_bitmask=1, running_handles=0xf34714) at multi.c:2235
#3  0x00007ffff6731627 in curl_multi_socket_action (multi_handle=0xf52180, s=<optimized out>,
    ev_bitmask=<optimized out>, running_handles=<optimized out>) at multi.c:2367
#4  0x00007ffff69ad5fb in NodeLibcurl::Multi::OnSocket (handle=0xef6ae8, status=0, events=1)
    at ../src/Multi.cc:187
#5  0x00000000009e5a40 in uv__io_poll (loop=0xeae720 <default_loop_struct>, timeout=-1)
    at ../deps/uv/src/unix/linux-core.c:308
#6  0x00000000009d9398 in uv_run (loop=0xeae720 <default_loop_struct>, mode=<optimized out>)
    at ../deps/uv/src/unix/core.c:317
#7  0x00000000009853ec in node::Start(int, char**) ()
---Type <return> to continue, or q <return> to quit---
#8  0x00007ffff6becec5 in __libc_start_main (main=0x9966a0 <main>, argc=2, argv=0x7fffffffdfe8,
    init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffdfd8)
    at libc-start.c:287
#9  0x00000000005a54a9 in _start ()

@JCMais
Copy link
Owner

JCMais commented Feb 8, 2016

Hi, thanks for all the info, I will have time to take a look into it by today or tomorrow.

I didn't tested ftp or ssh with the addon, probably I've forgot to add something. 😄

@johnnypez
Copy link
Author

No worries. I actually got it working with libcurl 7.47.1. Even though I had installed that earlier, the lib for 7.35.0 was still around and that was being used when node-libcurl was being installed. I had to add /usr/local/lib to /etc/ld.so.conf to get around it.

@JCMais
Copy link
Owner

JCMais commented Feb 8, 2016

As you got it working after updating libcurl I'm closing this since looks like the issue is from libcurl itself.

If the problem reappears feel free to reopen.

@JCMais JCMais closed this as completed Feb 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants