[zeromq-dev] zmq::poll.

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


Hello,

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
  sock.connect("tcp://localhost:12345");
  
  // 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
message:

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

Do I miss something?



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



More information about the zeromq-dev mailing list