[zeromq-dev] Problems with 2.0.6 poll using C++ api
Martin Sustrik
sustrik at 250bpm.com
Fri Mar 19 07:37:17 CET 2010
Matthew,
Yes, it looks like 0MQ believes that the two sockets belong to different
threads. Unfortunately, the problem doesn't reproduce on my box.
1. What OS you are running on?
2. Have a look at dispatcher.cpp, lines 146-154. The code there is
called when socket is created. It checks whether there's another socket
belonging to the same thread and if so, it chooses to share the same
app_thread_t object. Something probably goes wrong there. Can you check
it? Maybe current thread ID as returned by thread_t::id() is different
even if called twice from the same thread? Maybe thread ID comparison
function, thread_t::equal() is broken and returns false even if the two
thread IDs are the same?
Martin
> I'm simply trying to get the simplest possible 'polling' example
> working. I have two local PUB sockets sending a message every second, on
> ports 5550, 5551. The recv printout just verifies that I'm able to
> receive messages, prior to then attempting to poll.
>
> I actually exported CXXFLAGS="-ggdb3" and re-configured, make, make
> install. I still get the same error -- here's the latest gdb output:
>
> 342 for (int i = 0; i != nitems_; i++) {
> (gdb)
> 345 if (items_ [i].socket) {
> (gdb)
> 349 zmq::socket_base_t *s = (zmq::socket_base_t*) items_
> [i].socket;
> (gdb)
> 350 if (app_thread) {
> (gdb)
> 351 if (app_thread != s->get_thread ()) {
> (gdb)
> 352 free (pollfds);
> (gdb)
> 353 errno = EFAULT;
> (gdb)
> 354 return -1;
> (gdb)
> 630 }
> (gdb)
> zmq::poll (items_=0x7fffffffe1e0, nitems_=2, timeout_=-1) at
> /usr/local/include/zmq.hpp:54
> 54 if (rc < 0)
> (gdb)
> 55 throw error_t ();
> (gdb)
> terminate called after throwing an instance of 'zmq::error_t'
> what(): Bad address
>
> Program received signal SIGABRT, Aborted.
> 0x00007ffff5b0f4b5 in raise () from /lib/libc.so.6
> (gdb) bt
> #0 0x00007ffff5b0f4b5 in raise () from /lib/libc.so.6
> #1 0x00007ffff5b12f50 in abort () from /lib/libc.so.6
> #2 0x00007ffff65cacc5 in __gnu_cxx::__verbose_terminate_handler() ()
> from /usr/lib/libstdc++.so.6
> #3 0x00007ffff65c90f6 in ?? () from /usr/lib/libstdc++.so.6
> #4 0x00007ffff65c9123 in std::terminate() () from /usr/lib/libstdc++.so.6
> #5 0x00007ffff65c921e in __cxa_throw () from /usr/lib/libstdc++.so.6
> #6 0x0000000000404536 in zmq::poll (items_=0x7fffffffe1e0, nitems_=2,
> timeout_=-1) at /usr/local/include/zmq.hpp:55
> #7 0x0000000000404274 in main (argc=1, argv=0x7fffffffe358) at
> StrategyEngine.cpp:199
>
>
> Regards,
> -Matt
>
> On Thu, Mar 18, 2010 at 4:13 PM, Martin Lucina <mato at kotelna.sk
> <mailto:mato at kotelna.sk>> wrote:
>
> Hi Matthew,
>
> mgiedt at gmail.com <mailto:mgiedt at gmail.com> said:
> > Here's the application that I'm using to test:
> >
> > [snip]
>
> Looks fine though I'm not sure what you're trying to achieve...
>
> > This produces:
> >
> > sock1 recv: 0xfce9e8
> > sock2 recv: 0xfcece8
> > poll...
> > terminate called after throwing and instance of 'zmq::error_t'
> > what(): Bad address
> > Aborted
> >
> > I've included the gdb output below -- it's thinking that the two
> sockets were
> > created from different threads?
>
> That's what it looks like, but the trace you posted looks like it's
> bogus
> due to optimization. Can you try doing
>
> $ export CXXFLAGS="-O0 -g"
>
> Then rebuild and reinstall, and see if you a) still get the problem
> b) the
> backtrace looks sane?
>
> Thanks
>
> -mato
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
More information about the zeromq-dev
mailing list