Skip to content

segfault when zmq_poll() with closed socket #76

Description

@potatogim

Hi.

I met a segfault with my program.

this situation like below.

  1. call zmq_poll() with a monitor socket gained by zmq_monitor_socket() and then some callback is triggered.
  2. this callback checks connection and then if it is disconnected, close this socket.
  3. after that, call zmq_poll() with same pollitems.
  4. Bang!

I have rebuilt ZMQ::LibZMQ3 with ZMQ_TRACE.

1887                 mg = P5ZMQ3_Socket_mg_find( aTHX_ SvRV(*svr), &P5ZMQ3_Socket_vtbl );
1888
1889                 /* debugging logs added for tracing */
1890                 P5ZMQ3_TRACE(" + mg %d: %d", i, mg);
1891                 P5ZMQ3_TRACE(" + mg->mg_ptr %d: %d", i, mg->mg_ptr);
1892 
1893                 pollitems[i].socket = ((P5ZMQ3_Socket *) mg->mg_ptr)->socket;
1894                 P5ZMQ3_TRACE( " + via pollitem[%d].socket = %p", i, pollitems[i].socket );

and this is output from that.

[perlzmq (29306)] START mg_free (Message)
[perlzmq (29306)] + zmq message 2e41f50
[perlzmq (29306)] END mg_free (Message)
[perlzmq (29306)] START zmq_poll
[perlzmq (29306)] + processing element 0
[perlzmq (29306)] + mg 0: 48468640
[perlzmq (29306)] + mg->mg_ptr 0: 0
Segmentation fault (core dumped)

Actually... it may be my fault, too.

but I think that we can handle this situation more gracefully :)

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