[zeromq-dev] Segfault

Dhammika Pathirana dhammika at gmail.com
Sun Jan 2 06:35:46 CET 2011


Hi Douglas,

On Fri, Dec 31, 2010 at 7:08 PM, Douglas Creager <dcreager at dcreager.net> wrote:
> Friends,
>
> I've attached a quick test program that's giving me some segfaults on Mac OS with the latest git master.  I don't think there are any logic errors in the test case — if I've had a brain fart, please let me know.  It sends two two-part messages, using PUSH/PULL, with TCP connections and a high-water mark, all within a single thread.  When it happens, the segfault occurs in one of the zmq_close calls, or the zmq_term.  Any thoughts?  Or tips on how to further debug this?
>


There's a off by one indexing error in load balancer.
Shutdown code is bit gnarly. I've attached a patch below, but haven't tested it.


Subject: [PATCH] Fix pipe writer termination


Signed-off-by: Dhammika Pathirana <dhammika at gmail.com>
---
 src/pipe.cpp |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/pipe.cpp b/src/pipe.cpp
index bbdd44e..3f6f23b 100644
--- a/src/pipe.cpp
+++ b/src/pipe.cpp
@@ -275,7 +275,8 @@ void zmq::writer_t::terminate ()
     //  Prevent double termination.
     if (terminating)
         return;
-
+    terminating = true;
+
     //  Mark the pipe as not available for writing.
     active = false;

@@ -339,7 +340,7 @@ void zmq::writer_t::process_activate_writer
(uint64_t msgs_read_)

     //  If the writer was non-active before, let's make it active
     //  (available for writing messages to).
-    if (!active) {
+    if (!active && !terminating) {
         active = true;
         zmq_assert (sink);
         sink->activated (this);
-- 
1.7.0.4


Dhammika



More information about the zeromq-dev mailing list