Skip to content

node::Abort() in udpSocket.send(msg, port, address) if UDP socket is connected #28126

Description

@ibc
  • Version: v12.4.0
  • Platform: Darwin macbook 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64
  • Subsystem: dgram
const dgram = require('dgram');

const udpSocket = dgram.createSocket({ type: 'udp4' });

udpSocket.connect(1234, '127.0.0.1', (error) =>
{
  console.log('UDP socket connected (error:%s)', String(error));

  // This is the proper way to send data on a connected UDP socket.
  // udpSocket.send('foo', (error) => console.log('error:', error));

  // This is for non connected UDP sockets. Anyway it should NOT produce an abort.
  udpSocket.send('foo', 1234, '127.0.0.1', (error) => console.log('error:', error));
});

It produces:

UDP socket connected (error:undefined)
node[78453]: ../src/udp_wrap.cc:417:static void node::UDPWrap::DoSend(const FunctionCallbackInfo<v8::Value> &, int): Assertion `args[3]->IsUint32()' failed.
 1: 0x100075bd5 node::Abort() [/Users/ibc/.nvm/versions/node/v12.4.0/bin/node]
 2: 0x10007597d node::AppendExceptionLine(node::Environment*, v8::Local<v8::Value>, v8::Local<v8::Message>, node::ErrorHandlingMode) [/Users/ibc/.nvm/versions/node/v12.4.0/bin/node]
 3: 0x1001036f5 node::UDPWrap::DoSend(v8::FunctionCallbackInfo<v8::Value> const&, int) [/Users/ibc/.nvm/versions/node/v12.4.0/bin/node]
 4: 0x1001f0c84 v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) [/Users/ibc/.nvm/versions/node/v12.4.0/bin/node]
 5: 0x1001f0294 v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/Users/ibc/.nvm/versions/node/v12.4.0/bin/node]
 6: 0x1001ef840 v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/Users/ibc/.nvm/versions/node/v12.4.0/bin/node]
 7: 0x100ea9f02 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/Users/ibc/.nvm/versions/node/v12.4.0/bin/node]
Abort trap: 6

To clarify, the code above creates a UDP socket, connects it, and then uses the send() API by including the remote port and address (which are useless or even invalid in a connected UDP socket).

Not sure if send() should throw due the useless/invalid presence of port and address arguments, but it should not crash.

Activity

  1. ibc commented on Jun 8, 2019

    @ibc
    Author

    Note that, according to the libuv UDP handle:

    For connected UDP handles, addr must be set to NULL, otherwise it will return UV_EISCONN error.

    For connectionless UDP handles, addr cannot be NULL, otherwise it will return UV_EDESTADDRREQ error.

    However, the issue here is a CHECK(args[2]->IsUint32()) in udp_wrap.cc that causes the above abort.

  2. added a commit that references this issue on Jun 10, 2019
  3. added a commit that references this issue on Jun 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions