Hi Ilja,

Works ok with master branch, but there's a bug in initializing
zmq::context_t with 0 io threads.
I've attached following patch,

diff --git a/src/ctx.cpp b/src/ctx.cpp
index 65c5316..ec8a045 100644
--- a/src/ctx.cpp
+++ b/src/ctx.cpp
@@ -64,7 +64,7 @@ zmq::ctx_t::ctx_t (uint32_t io_threads_) :
     }

     //  In the unused part of the slot array, create a list of empty slots.
-    for (uint32_t i = slot_count - 1; i >= io_threads_; i--) {
+    for (uint32_t i = io_threads_; i < slot_count; i++) {
         empty_slots.push_back (i);
         slots [i] = NULL;
     }
-- 



On Mon, Sep 6, 2010 at 4:15 AM, Ilja Golshtein <[email protected]> wrote:
> Hello,
>
> I think I can say for sure the crash caused by 0mq.
> 2.0.7 and 2.0.8 behave in the same way.
>
> If put something like sleep(1) before the end of send_thread try block, 
> everything is fine.
> Serialising of erasing push sockets in send_thread by mutex does not help 
> though.
>
> Thanks.
>
> 06.09.10, 14:04, "Ilja Golshtein" <[email protected]>:
>
>> Hello!
>>
>>  The application http://pastebin.com/yJY5xgts
>>  produces following trace
>>  ==
>>  (gdb) thread 1
>>  [Switching to thread 1 (Thread 2025)]#0  0x00002abfca190265 in raise (
>>      sig=) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
>>  64        return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
>>  (gdb) bt
>>  #0  0x00002abfca190265 in raise (sig=)
>>      at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
>>  #1  0x00002abfca191d10 in abort () at abort.c:88
>>  #2  0x00002abfca1ca84b in __libc_message (do_abort=2,
>>      fmt=0x2abfca282348 "*** glibc detected *** %s: %s: 0x%s ***\n")
>>      at ../sysdeps/unix/sysv/linux/libc_fatal.c:170
>>  #3  0x00002abfca1d230f in malloc_printerr (av=0x2abfca4b29e0, 
>> p=0x2aaab0003340,
>>      have_lock=0) at malloc.c:6205
>>  #4  _int_free (av=0x2abfca4b29e0, p=0x2aaab0003340, have_lock=0) at 
>> malloc.c:4738
>>  #5  0x00002abfca1d276b in __libc_free (mem=) at malloc.c:3670
>>  #6  0x00002abfc97adf98 in pop (this=0x2aaaac000bb0, msg_=0x40ef4080) at 
>> yqueue.hpp:160
>>  #7  read (this=0x2aaaac000bb0, msg_=0x40ef4080) at ypipe.hpp:161
>>  #8  zmq::reader_t::read(._0 *) (this=0x2aaaac000bb0, msg_=0x40ef4080) at 
>> pipe.cpp:77
>>  #9  0x00002abfc97a8a59 in zmq::fq_t::recv(._0 *, int) (this=0xd753480, 
>> msg_=0x40ef4080,
>>      flags_=) at fq.cpp:86
>>  #10 0x00002abfc97b5bc4 in zmq::socket_base_t::recv(._78 *, int) 
>> (this=0x7e8, msg_=0x7e9,
>>      flags_=6) at socket_base.cpp:387
>>  #11 0x00000000004040e5 in zmq::socket_t::recv(zmq::message_t*, int) ()
>>  #12 0x000000000040336c in recv_thread(void*) ()
>>  #13 0x00002abfc957573d in start_thread (arg=)
>>      at pthread_create.c:301
>>  #14 0x00002abfca233d1d in clone () from /lib64/libc.so.6
>>  ==
>>  if number of threads is 5 or more.
>>
>>  Command line parameters - number of threads.
>>
>>  Currently investigating though I am 90% sure the roots are inside 0mq.
>>
>>  > uname -a
>>  Linux dev 2.6.18-194.3.1.el5 #1 SMP Thu May 13 13:08:30 EDT 2010 x86_64 
>> x86_64 x86_64 GNU/Linux
>>  >rpm -qa | grep zeromq
>>  zeromq-devel-2.0.8-1
>>  zeromq-debuginfo-2.0.8-1
>>  zeromq-2.0.8-1
>>
>>
>>
>
> --
> Best regards,
> Ilja Golshtein.
> _______________________________________________
> zeromq-dev mailing list
> [email protected]
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
From 38eef77c3015cf4de741650fe8a0a155193bbc26 Mon Sep 17 00:00:00 2001
From: dhammika <[email protected]>
Date: Mon, 6 Sep 2010 19:32:31 -0700
Subject: [PATCH] fix zmq_context constructor with 0 io_threads


Signed-off-by: dhammika <[email protected]>
---
 src/ctx.cpp |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/ctx.cpp b/src/ctx.cpp
index 65c5316..ec8a045 100644
--- a/src/ctx.cpp
+++ b/src/ctx.cpp
@@ -64,7 +64,7 @@ zmq::ctx_t::ctx_t (uint32_t io_threads_) :
     }
 
     //  In the unused part of the slot array, create a list of empty slots.
-    for (uint32_t i = slot_count - 1; i >= io_threads_; i--) {
+    for (uint32_t i = io_threads_; i < slot_count; i++) {
         empty_slots.push_back (i);
         slots [i] = NULL;
     }
-- 
1.7.0.4

_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to