[zeromq-dev] zmq::poll.

Skrzyniarz Alexandre alexandre.skrzyniarz at fr.thalesgroup.com
Tue Mar 1 17:58:42 CET 2011


I guess I need some help with zmq::poll

I want to use zmq::poll, but I stumbled upon a segmentation fault issue.
I run a 64 bits debian linux operating system, with zmq 2.0.10

This sample code reproduce the issue:

#include <iostream>
#include <zmq.hpp>

int main ( int, char * [] )
  // create context
  zmq::context_t ctx (1);
  // create subscriber socket
  zmq::socket_t sock (ctx, ZMQ_SUB);
  // filter messages
  sock.setsockopt( ZMQ_SUBSCRIBE, "xy.z", 4);
  // connect
  // poll
  zmq_pollitem_t item;
  item.socket = (void *)&sock;
  item.fd = 0;
  item.events = ZMQ_POLLIN;
  item.revents = 0;
  int rc = zmq::poll (&item, 1, -1);
  std::cerr << "rc: " << rc << std::endl;

  return 0;

The program segfault when calling zmq::poll.
According to the core file, the error occurs in zmq.cpp, line 480.

with zeromq 2.1.1, the program doesn't crashes, but aborts with this

Bad file descriptor
nbytes != -1 (mailbox.cpp:241)

Do I miss something?

Alexandre SKRZYNIARZ, PhD.
[EXPERTS] Domain Design Authority, Radar & Warfare Systems.
10 Av 1ere DFL, 29200 BREST, France
email: alexandre.skrzyniarz at fr.thalesgroup.com

More information about the zeromq-dev mailing list