Repository: nodejs/node-v0.x-archive

Issue #1191: Fatal error in node/deps/v8/src/api.cc, line 2359
Created: 2011-06-17T00:18:09Z
Breaks with 0.4.8 and master. Seems to be some kind of C++/JS binding error.
// good.js
require('http').get({host:'google.com', path:'/'}, function(res) {
    res.on('data', function(data) {
        process.stdout.write(data);
    });
}).end();

.
// bad.js
require('http').get({host:'google.com', path:'/'}, function(res) {
    res.on('data', process.stdout.write);
}).end();

https://gist.github.com/5ee90690dbcd384f5780
This works:
$ ./node_g good.js 
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>

This breaks:
$ ./node_g bad.js


#
# Fatal error in /home/bnoordhuis/src/nodejs/node/deps/v8/src/api.cc, line 2359
# CHECK(!i::Top::external_caught_exception()) failed
#

Aborted

==== Stack trace ============================================

Security context: 0x7f276215d201 <JS Object>#0#
    1: ondata [http.js:1228] (this=0x7f273bd1cc99 <a Socket>>#1#,d=0x7f273bd20829 <a Buffer>>#2#,start=0,end=530)
    2: _onReadable [net.js:684] (this=0x7f273bd1cc99 <a Socket>>#1#)
    3: callback(aka onReadable) [net.js:177] (this=0x7f273bd1d1b9 <an IOWatcher>>#3#,readable=0x7f27620ec101 <true>,writable=0x7f27620ec139 <false>)

==== Details ================================================

[1]: ondata [http.js:1228] (this=0x7f273bd1cc99 <a Socket>>#1#,d=0x7f273bd20829 <a Buffer>>#2#,start=0,end=530) {
  // stack-allocated locals
  var bytesParsed = 0x7f27620ec079 <undefined>
  var ret = 0x7f27620ec079 <undefined>
  var res = 0x7f27620ec079 <undefined>
  var upgradeHead = 0x7f27620ec079 <undefined>
  // expression stack (top to bottom)
  [08] : 0x7f273bda32c9 <JS Function execute>#4#
  [07] : 530
  [06] : 0
  [05] : 0x7f273bd20829 <a Buffer>>#2#
  [04] : 0x7f273bd90021 <an HTTPParser>>#5#
--------- s o u r c e   c o d e ---------
function (d, start, end) {?    var ret = parser.execute(d, start, end - start);?    if (ret instanceof Error) {?      debug('parse error');?      socket.destroy(ret);?    } else if (parser.incoming && parser.incoming.upgrade) {?      var bytesParsed = ret;?      socket.ondata = null;?      socket.onend = nul...

-----------------------------------------
}

[2]: _onReadable [net.js:684] (this=0x7f273bd1cc99 <a Socket>>#1#) {
  // stack-allocated locals
  var .catch-var = 0x7f27620ec079 <undefined>
  // heap-allocated locals
  var .arguments = 0x7f275c000071 <an Arguments>>#6#
  var self = 0x7f273bd1cc99 <a Socket>>#1#
  var string = 0x7f27620ec079 <undefined>
  var end = 530
  var bytesRead = 530
  var arguments = 0x7f275c000071 <an Arguments>>#6#
  var start = 0
  // expression stack (top to bottom)
  [04] : 530
  [03] : 0
  [02] : 0x7f273bd20829 <a Buffer>>#2#
  [01] : 0x7f273bd1cc99 <a Socket>>#1#
--------- s o u r c e   c o d e ---------
function () {?  var self = this;??  // If this is the first recv (pool doesn't exist) or we've used up?  // most of the pool, allocate a new one.?  if (!pool || pool.length - pool.used < kMinPoolSpace) {?    // discard the old pool. Can't add to the free list because?    // users might have refernces to slic...

-----------------------------------------
}

[3]: callback(aka onReadable) [net.js:177] (this=0x7f273bd1d1b9 <an IOWatcher>>#3#,readable=0x7f27620ec101 <true>,writable=0x7f27620ec139 <false>) {
  // stack-allocated locals
  var socket = 0x7f273bd1cc99 <a Socket>>#1#
  // expression stack (top to bottom)
  [01] : 0x7f273bd1cc99 <a Socket>>#1#
--------- s o u r c e   c o d e ---------
function onReadable(readable, writable) {?  assert(this.socket);?  var socket = this.socket;?  socket._onReadable();?}
-----------------------------------------
}

==== Key         ============================================

 #0# 0x7f276215d201: 0x7f276215d201 <JS Object>
 #1# 0x7f273bd1cc99: 0x7f273bd1cc99 <a Socket>>
        remotePort: 80
           _events: 0x7f273bd8f319 <an Object>>#7#
       _connecting: 0x7f27620ec139 <false>
      _httpMessage: 0x7f273bd1bb81 <a ClientRequest>>#8#
     _writeWatcher: 0x7f273bd1db09 <an IOWatcher>>#9#
         destroyed: 0x7f27620ec139 <false>
     remoteAddress: 0x7f273bccc031 <String[12]: 74.125.77.99>
_writeQueueEncoding: 0x7f273bd1d671 <JS array[0]>#10#
       _writeQueue: 0x7f273bd1d519 <JS array[0]>#11#
                fd: 6
      _readWatcher: 0x7f273bd1d1b9 <an IOWatcher>>#3#
          writable: 0x7f27620ec101 <true>
   _httpConnecting: 0x7f27620ec139 <false>
_writeQueueCallbacks: 0x7f273bd1d969 <JS array[0]>#12#
              type: 0x7f2762111359 <String[4]: tcp4>
        bufferSize: 0
     allowHalfOpen: 0x7f27620ec139 <false>
     _writeQueueFD: 0x7f273bd1d7e1 <JS array[0]>#13#
          readable: 0x7f27620ec101 <true>
 #2# 0x7f273bd20829: 0x7f273bd20829 <a Buffer>>
              used: 530
            length: 40960
            offset: 0
            parent: 0x7f273bd20921 <a SlowBuffer>>#14#
 #3# 0x7f273bd1d1b9: 0x7f273bd1d1b9 <an IOWatcher>>
            socket: 0x7f273bd1cc99 <a Socket>>#1#
          callback: 0x7f273bd7a6f1 <JS Function onReadable>#15#
 #4# 0x7f273bda32c9: 0x7f273bda32c9 <JS Function execute>
 #5# 0x7f273bd90021: 0x7f273bd90021 <an HTTPParser>>
             field: 0x7f27620ec021 <null>
            socket: 0x7f273bd1cc99 <a Socket>>#1#
             value: 0x7f27620ec021 <null>
          incoming: 0x7f275c0009f9 <an IncomingMessage>>#16#
 #6# 0x7f275c000071: 0x7f275c000071 <an Arguments>>
            callee: 0x7f273bddc631 <JS Function>#17#
            length: 0
 #7# 0x7f273bd8f319: 0x7f273bd8f319 <an Object>>
           connect: 0x7f273bd1cc51 <JS Function>#18#
             close: 0x7f273bd90b91 <JS Function>#19#
             error: 0x7f273bd90651 <JS Function>#20#
 #8# 0x7f273bd1bb81: 0x7f273bd1bb81 <a ClientRequest>>
useChunkedEncodingByDefault: 0x7f27620ec139 <false>
           _events: 0x7f273bd913f1 <an Object>>#21#
   outputEncodings: 0x7f273bd1bcb1 <JS array[0]>#22#
   shouldKeepAlive: 0x7f27620ec139 <false>
          _hasBody: 0x7f27620ec101 <true>
             _last: 0x7f27620ec101 <true>
      _headerNames: 0x7f273bd1c7f1 <an Object>>#23#
               res: 0x7f275c0009f9 <an IncomingMessage>>#16#
            socket: 0x7f273bd1cc99 <a Socket>>#1#
          _headers: 0x7f273bd1c659 <an Object>>#24#
            method: 0x7f273bcbfda9 <String[3]: GET>
          finished: 0x7f27620ec101 <true>
       _headerSent: 0x7f27620ec101 <true>
        connection: 0x7f273bd1cc99 <a Socket>>#1#
   chunkedEncoding: 0x7f27620ec139 <false>
              path: 0x7f27620fd209 <String[1]: />
             agent: 0x7f273bd1b271 <an Agent>>#25#
          writable: 0x7f27620ec101 <true>
            output: 0x7f273bd1bc29 <JS array[0]>#26#
          _trailer: 0x7f27620f0531 <String[0]: >
            _queue: 0x7f27620ec021 <null>
           _header: 0x7f273bccc0d1 <String[55]\: GET / HTTP/1.1\r\nHost: google.com\r\nConnection: close\r\n\r\n>
 #9# 0x7f273bd1db09: 0x7f273bd1db09 <an IOWatcher>>
            socket: 0x7f273bd1cc99 <a Socket>>#1#
          callback: 0x7f273bd7a6a9 <JS Function onWritable>#27#
 #10# 0x7f273bd1d671: 0x7f273bd1d671 <JS array[0]>
 #11# 0x7f273bd1d519: 0x7f273bd1d519 <JS array[0]>
 #12# 0x7f273bd1d969: 0x7f273bd1d969 <JS array[0]>
 #13# 0x7f273bd1d7e1: 0x7f273bd1d7e1 <JS array[0]>
 #14# 0x7f273bd20921: 0x7f273bd20921 <a SlowBuffer>>
            length: 40960
 #15# 0x7f273bd7a6f1: 0x7f273bd7a6f1 <JS Function onReadable>
 #16# 0x7f275c0009f9: 0x7f275c0009f9 <an IncomingMessage>>
           upgrade: 0x7f27620ec139 <false>
           _events: 0x7f275c004f21 <an Object>>#28#
          complete: 0x7f27620ec139 <false>
  httpVersionMajor: 1
          trailers: 0x7f275c000fa1 <an Object>>#29#
            socket: 0x7f273bd1cc99 <a Socket>>#1#
            method: 0x7f27620ec021 <null>
           headers: 0x7f275c000e21 <an Object>>#30#
       httpVersion: 0x7f275c004681 <String[3]: 1.1>
        connection: 0x7f273bd1cc99 <a Socket>>#1#
            client: 0x7f273bd1cc99 <a Socket>>#1#
        statusCode: 301
  httpVersionMinor: 1
               url: 0x7f27620f0531 <String[0]: >
          readable: 0x7f27620ec101 <true>
 #17# 0x7f273bddc631: 0x7f273bddc631 <JS Function>
 #18# 0x7f273bd1cc51: 0x7f273bd1cc51 <JS Function>
 #19# 0x7f273bd90b91: 0x7f273bd90b91 <JS Function>
 #20# 0x7f273bd90651: 0x7f273bd90651 <JS Function>
 #21# 0x7f273bd913f1: 0x7f273bd913f1 <an Object>>
 #22# 0x7f273bd1bcb1: 0x7f273bd1bcb1 <JS array[0]>
 #23# 0x7f273bd1c7f1: 0x7f273bd1c7f1 <an Object>>
              host: 0x7f27620fef89 <String[4]: Host>
 #24# 0x7f273bd1c659: 0x7f273bd1c659 <an Object>>
              host: 0x7f273bcbe151 <String[10]: google.com>
 #25# 0x7f273bd1b271: 0x7f273bd1b271 <an Agent>>
           sockets: 0x7f273bd1b5b9 <JS array[1]>#31#
              host: 0x7f273bcbe151 <String[10]: google.com>
        socketPath: 0x7f27620ec079 <undefined>
           options: 0x7f273bd1b171 <an Object>>#32#
             queue: 0x7f273bd1b4d1 <JS array[0]>#33#
              port: 80
        maxSockets: 5
 #26# 0x7f273bd1bc29: 0x7f273bd1bc29 <JS array[0]>
 #27# 0x7f273bd7a6a9: 0x7f273bd7a6a9 <JS Function onWritable>
 #28# 0x7f275c004f21: 0x7f275c004f21 <an Object>>
               end: 0x7f275c004ed9 <JS Function>#34#
 #29# 0x7f275c000fa1: 0x7f275c000fa1 <an Object>>
 #30# 0x7f275c000e21: 0x7f275c000e21 <an Object>>
 #31# 0x7f273bd1b5b9: 0x7f273bd1b5b9 <JS array[1]>
                 0: 0x7f273bd1cc99 <a Socket>>#1#
 #32# 0x7f273bd1b171: 0x7f273bd1b171 <an Object>>
              host: 0x7f273bcbe151 <String[10]: google.com>
              port: 80
 #33# 0x7f273bd1b4d1: 0x7f273bd1b4d1 <JS array[0]>
 #34# 0x7f275c004ed9: 0x7f275c004ed9 <JS Function>
=====================

Duplicate issue #220: http-parser should pause
Created: 2010-07-26T18:26:40Z
a test case for the required behavior http://gist.github.com/490989

Closing comment (2011-07-03T17:54:12Z): This has been fixed (I think) but interestingly, that test case causes an assertion error in V8.
#
# Fatal error in /home/bnoordhuis/src/nodejs/node/deps/v8/src/api.cc, line 2692
# CHECK(!(isolate)->external_caught_exception()) failed   
#


==== Stack trace ============================================

Security context: 0x7f3197371251 <JS Object>#0#
    1: ondata [http.js:1019] (this=0x7f31930c7321 <a Socket>>#1#,d=0x7f31930c5ff9 <a Buffer>>#2#,start=0,end=81)
    2: _onReadable [net_legacy.js:683] (this=0x7f31930c7321 <a Socket>>#1#)
    3: callback(aka onReadable) [net_legacy.js:177] (this=0x7f31930c7641 <an IOWatcher>>#3#,readable=0x7f31972fc129 <true>,writable=0x7f31972fc169 <false>)

Probably related to #1191.