Program: 4006
Project: 4006
Buggy source:
@Override public void onEvent(Object raw) throws Exception {
  ByteBuffer d=(ByteBuffer)raw;
  ClientRequest req=(ClientRequest)socket.get_httpMessage();
  parserOnIncomingClient parser=(parserOnIncomingClient)socket.getParser();
  assert(parser != null && parser.socket == socket);
  int ret=parser.Execute(d);
  if (ret < 0) {
    Log.d(TAG,"String_Node_Str");
    IncomingParser.freeParser(parser,req);
    socket.destroy(null);
    req.emit("String_Node_Str","String_Node_Str");
    req.socket.set_hadError(true);
  }
 else   if (parser.incoming != null && parser.incoming.isUpgrade()) {
    int bytesParsed=ret;
    IncomingMessage res=parser.incoming;
    req.res=res;
    socket.removeListener("String_Node_Str",socketOnData);
    socket.removeListener("String_Node_Str",socketOnEnd);
    parser.Finish();
    ByteBuffer bodyHead=(ByteBuffer)Util.chunkSlice(d,bytesParsed);
    String eventName=req.method == "String_Node_Str" ? "String_Node_Str" : "String_Node_Str";
    if (req.listenerCount(eventName) > 0) {
      req.upgradeOrConnect=true;
      socket.emit("String_Node_Str");
      socket.removeListener("String_Node_Str",socketCloseListener);
      socket.removeListener("String_Node_Str",socketErrorListener);
      socket.get_readableState().setFlowing(TripleState.MAYBE);
      req.emit(eventName,new HTTP.response_socket_head_b(res,socket,bodyHead));
      req.emit("String_Node_Str");
    }
 else {
      socket.destroy(null);
    }
    IncomingParser.freeParser(parser,req);
  }
 else   if (parser.incoming != null && parser.incoming.isComplete() && parser.incoming.statusCode() != 100) {
    socket.removeListener("String_Node_Str",socketOnData);
    socket.removeListener("String_Node_Str",socketOnEnd);
    IncomingParser.freeParser(parser,req);
  }
}

Fixed version (ground truth):
@Override public void onEvent(Object raw) throws Exception {
  ByteBuffer d=(ByteBuffer)raw;
  ClientRequest req=(ClientRequest)socket.get_httpMessage();
  parserOnIncomingClient parser=(parserOnIncomingClient)socket.getParser();
  assert(parser != null && parser.socket == socket);
  int ret=parser.Execute(d);
  if (ret < 0) {
    Log.d(TAG,"String_Node_Str");
    IncomingParser.freeParser(parser,req);
    socket.destroy(null);
    req.emit("String_Node_Str","String_Node_Str");
    req.socket.set_hadError(true);
  }
 else   if (parser.incoming != null && parser.incoming.isUpgrade()) {
    int bytesParsed=ret;
    IncomingMessage res=parser.incoming;
    req.res=res;
    socket.removeListener("String_Node_Str",socketOnData);
    socket.removeListener("String_Node_Str",socketOnEnd);
    parser.Finish();
    ByteBuffer bodyHead=(ByteBuffer)Util.chunkSlice(d,bytesParsed);
    String eventName=req.method == "String_Node_Str" ? "String_Node_Str" : "String_Node_Str";
    if (req.listenerCount(eventName) > 0) {
      req.upgradeOrConnect=true;
      socket.emit("String_Node_Str");
      socket.removeListener("String_Node_Str",socketCloseListener);
      socket.removeListener("String_Node_Str",socketErrorListener);
      socket.get_readableState().setFlowing(TripleState.MAYBE);
      req.emit(eventName,new http.response_socket_head_b(res,socket,bodyHead));
      req.emit("String_Node_Str");
    }
 else {
      socket.destroy(null);
    }
    IncomingParser.freeParser(parser,req);
  }
 else   if (parser.incoming != null && parser.incoming.isComplete() && parser.incoming.statusCode() != 100) {
    socket.removeListener("String_Node_Str",socketOnData);
    socket.removeListener("String_Node_Str",socketOnEnd);
    IncomingParser.freeParser(parser,req);
  }
}