Serious bug in http client (node 0.1.30)

43 views
Skip to first unread message

kokucha

unread,
Feb 22, 2010, 10:02:18 PM2/22/10
to nodejs
Guys,

Just found a serious bug in the http client. When I make a request to
an unreachable server or to a firewalled port and set a timeout on the
client, node won't close the connection when the timeout is reached,
and it will be sending 'timeout' events indefinitely while keeping the
socket open in SYN_SENT state. Also tried to do "client.forceClose()"
after receiving a 'timeout' event, but node just segfaults.

Here's a simple test case: http://gist.github.com/311783

And here's a sample output (202.129.49.242 is an unreachable IP):

$ node test.js http://202.129.49.242:8030/
DEBUG: [1002] Timeout: undefined
DEBUG: [60004] Timeout: undefined
DEBUG: [60004] Timeout: undefined
DEBUG: [60004] Timeout: undefined
DEBUG: [60004] Timeout: undefined
Closing...
Segmentation fault
$

Here's what I get from GDB:

1) http://gist.github.com/311784 (dies in node_net.cc:262
assert(connection->host_ == NULL);)

After commenting that line, I get:

2) http://gist.github.com/311791 (dies in node_net.cc:296
assert(connection->refs_);)

After commenting that line, I get:

3) http://gist.github.com/311793 (dies in node_net.cc:325
assert(connection->refs_);)

After commenting that line, I get:

4) http://gist.github.com/311796 (dies in node_net.cc:201
assert(stream_.recvfd < 0 && "garbage collecting open Connection");)

After commenting that line, I get:

5) http://gist.github.com/311799 (dies in node_net.cc:202
assert(stream_.sendfd < 0 && "garbage collecting open Connection");)

After commenting that line, I finally get the segfault:

6) http://gist.github.com/311802 (segfaults)


Sorry if I'm being too verbose, I just want to help as much as
possible. Let me know if you need anything else.

Cheers,
Peter

Ryan Dahl

unread,
Feb 23, 2010, 1:25:25 AM2/23/10
to nod...@googlegroups.com
On Mon, Feb 22, 2010 at 7:02 PM, kokucha <delak...@hotmail.com> wrote:
> Guys,
>
> Just found a serious bug in the http client. When I make a request to
> an unreachable server or to a firewalled port and set a timeout on the
> client, node won't close the connection when the timeout is reached,
> and it will be sending 'timeout' events indefinitely while keeping the
> socket open in SYN_SENT state. Also tried to do "client.forceClose()"
> after receiving a 'timeout' event, but node just segfaults.

Yeah - that seems to be a problem. Try the attached very hacky fix.

I'd like to have a nice test/mjsunit test for this but I haven't been
able to do figure out something self-contained.

0001-Add-hack-to-get-error-event-on-socket-timeout.patch

kokucha

unread,
Feb 23, 2010, 9:21:18 AM2/23/10
to nodejs
It seems to have fixed it. Thanks!

It'd be nice, though, to have an error description like 'timeout' when
the 'error' event is sent after the timeout.

I could try to write a a mjsunit test for this. Isn't the script I
posted above self-contained?

On Feb 23, 3:25 am, Ryan Dahl <coldredle...@gmail.com> wrote:

>  0001-Add-hack-to-get-error-event-on-socket-timeout.patch
> 1KViewDownload

Ryan Dahl

unread,
Feb 24, 2010, 4:25:30 PM2/24/10
to nod...@googlegroups.com
On Tue, Feb 23, 2010 at 6:21 AM, kokucha <delak...@hotmail.com> wrote:
> It seems to have fixed it. Thanks!
>
> It'd be nice, though, to have an error description like 'timeout' when
> the 'error' event is sent after the timeout.
>
> I could try to write a a mjsunit test for this. Isn't the script I
> posted above self-contained?

Self-contained would be one that doesn't rely on a certain internet
address being in a certain state.

Reply all
Reply to author
Forward
0 new messages