Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

crash when calling Socket.resume() immediately after connect() #3402

Closed
clowwindy opened this issue Jun 11, 2012 · 5 comments
Closed

crash when calling Socket.resume() immediately after connect() #3402

clowwindy opened this issue Jun 11, 2012 · 5 comments
Labels

Comments

@clowwindy
Copy link

Program:

var net = require('net');

var conn = net.connect('www.google.com', 80, function() {
  conn.close();
});
conn.resume();

Result:

$ ./node-centos-64bit/node test.js
node: src/unix/stream.c:944: uv__read_start_common: Assertion `stream->fd >= 0' failed.
Aborted (core dumped)

$ ./node-centos-64bit/node --version   
v0.6.19

$ gdb ./node-centos-64bit/node core.28683
(skipped)
Core was generated by `./node-centos-64bit/node test.js'.
Program terminated with signal 6, Aborted.
#0  0x0000003f73632885 in raise () from /lib64/libc.so.6

$ cat /etc/issue
CentOS release 6.2 (Final)
Kernel \r on an \m
@clowwindy
Copy link
Author

Test also failed on Ubuntu 12.04 LTS 32bit:

$ node test.js
node: src/unix/stream.c:934: uv__read_start_common: Assertion `stream->fd >= 0' failed.
Aborted (core dumped)
$ node --version
v0.6.12

And OSX Lion:

clowwindy@clowwindy:~/tmp$ node test.js
Assertion failed: (stream->fd >= 0), function uv__read_start_common, file src/unix/stream.c, line 937.
Abort trap: 6
clowwindy@clowwindy:~/tmp$ node --version
v0.6.15

However, test passed on Windows as an Javascript Error had been raised:

$ node test.js

events.js:48
        throw arguments[1]; // Unhandled 'error' event
                       ^
Error: connect ENOENT
    at errnoException (net.js:670:11)
    at Object.afterConnect [as oncomplete] (net.js:661:19)

$ node --version
v0.6.18

Seems only crash on Linux/Unix?

@indutny
Copy link
Member

indutny commented Jun 11, 2012

Possible fixes (both for node's core):

  1. Add this._connecting !== true check to .resume and .pause methods of Socket constructor.
  2. Add this.readable === true check to the same methods.

Though this problem may be fixed in libuv too. @bnoordhuis @piscisaureus what do you think?

@indutny
Copy link
Member

indutny commented Jun 11, 2012

Problem is that fd doesn't exist until dns lookup finishes.

@indutny
Copy link
Member

indutny commented Jun 11, 2012

See joyent/libuv#460 for proposed fix.

@bnoordhuis
Copy link
Member

A provisional patch for this issue landed in de65ba7. We're going to fix it properly in libuv sometime after v0.8.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants