Issue #12 invalid

Receiving "Assertion `!(handle->flags & (UV_CLOSING | UV_CLOSED))' failed" error after a number of pings

Adam Zochowski
created an issue

Net Ping crashes node

Example Code

var ping = require ("net-ping");

setInterval(function(){
    var session = ping.createSession ({ retries: 0, timeout: 1000 });

    session.pingHost ("4.2.2.2", function (error, target, sent, rcvd) {
        if (error) {
            console.log (sent+ " : " + target + " : "+(rcvd-sent)+ "ms ** " + error.toString ());
        } else {
            console.log (sent+ " : " + target + " : "+(rcvd-sent)+ "ms ALIVE " );
        }
        session.close();
    });}, 200 );

Alternate Code Example

in case the issue is with running too many sessions, here is same code performing everything within a single session:

var ping = require ("net-ping");
var session = ping.createSession ({ retries: 0, timeout: 1000 });

setInterval(function(){

    session.pingHost ("4.2.2.2", function (error, target, sent, rcvd) {
        if (error) {
            console.log (sent+ " : " + target + " : "+(rcvd-sent)+ "ms ** " + error.toString ());
        } else {
            console.log (sent+ " : " + target + " : "+(rcvd-sent)+ "ms ALIVE " );
        }
    });}, 200 );

Description what is happening

  • First couple dozen pings are all ok, 40ms.
  • Second couple dozen pings are timed out.
  • Eventually nodejs crashes:

nodejs: ../deps/uv/src/unix/poll.c:75: uv_poll_stop: Assertion `!(handle->flags & (UV_CLOSING | UV_CLOSED))' failed.

Version tested

  • node-net-ping v1.1.9
  • node v 0.10.9
  • Linux 3.8.0-28-generic #41-Ubuntu SMP Fri Jul 26 16:26:01 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Comments (7)

  1. Stephen Vickers repo owner

    Hi adamzochowski,

    Thanks for reporting the issue.

    The net-ping module uses the raw-socket module, which is downloaded and compiled during the install of net-ping. I believe the issue is in the raw-socket module.

    Can you please locate the file "raw.cc" which should be under the "node_modules/raw-socket/src" directory and modify lines 311 to 316:

                    uv_poll_stop (&this->poll_watcher_);
                    closesocket (this->poll_fd_);
                    this->poll_fd_ = INVALID_SOCKET;
    
                    uv_close ((uv_handle_t *) &this->poll_watcher_, OnClose);
                    this->poll_initialised_ = false;
    

    To the following:

                    uv_close ((uv_handle_t *) &this->poll_watcher_, OnClose);
                    closesocket (this->poll_fd_);
                    this->poll_fd_ = INVALID_SOCKET;
                    this->poll_initialised_ = false;
    

    Then recompile using:

    cd node_modules/raw-socket
    node-gyp rebuild
    

    Then see if that resolves the issue for you?

    Thanks

    Steve

  2. Adam Zochowski reporter

    Hi, perfect, it no longer crashes!

    And on a related note: I just resolved my timeouts. My gateway or isp has a throttle on ICMP, so it lets few fast through, but eventually blocks them off.

    Thank you very much Adam

  3. Stephen Vickers repo owner

    Also, forgot to mention, since the issue is raw-socket related I'll open a ticket under that project, refer to this one from that, and close this ticket.

  4. Log in to comment