Hi,

I'm seeing a segmentation fault in zmq_msg_close() called from
zmq::pipe_t::~pipe_t(). This is on 2.0.8 with a Python application so the
problem may be related to Python memory management issues, but maybe not.

Here's the backtrace:

#0  0x00007f19fbd299cf in zmq_msg_close (msg_=0x7fffffffb900) at zmq.cpp:171
#1  0x00007f19fbd12018 in ~pipe_t (this=0x7f19f4080de0) at pipe.cpp:333
#2  0x00007f19fbd10b7b in zmq::reader_t::process_pipe_term_ack 
(this=0x7f19f4080e40) at pipe.cpp:123
#3  0x00007f19fbd0dc66 in zmq::object_t::process_command (this=0x7f19f4080e40, 
cm...@0x7fffffffba10) at object.cpp:102
#4  0x00007f19fbcfe916 in zmq::app_thread_t::process_commands (this=0x8afeb0, 
block_=false, throttle_=false)
    at app_thread.cpp:128
#5  0x00007f19fbd2a21a in zmq_poll (items_=0x7a51c0, nitems_=4, timeout_=-1000) 
at zmq.cpp:448
#6  0x00007f19fbf613ce in __pyx_pf_3zmq_4_zmq__poll (__pyx_self=, 
__pyx_args=0x85f550, 
    __pyx_kwds=) at zmq/_zmq.c:7856
#7  0x00000000004919c2 in PyEval_EvalFrameEx ()
[...]

Looking at the code in zmq_msg_close():

164    zmq::msg_content_t *content = (zmq::msg_content_t*) msg_->content;
165    if (!(msg_->flags & ZMQ_MSG_SHARED) || !content->refcnt.sub (1)) {
166
167        //  We used "placement new" operator to initialize the reference.
168        //  counter so we call its destructor now.
169        content->refcnt.~atomic_counter_t ();
170
171        if (content->ffn)
172            content->ffn (content->data, content->hint);
173        free (content);
174    }

What is interesting is that it fails on line 172, and msg_ is all NULLs:

(gdb) p *msg_
$2 = {content = 0x0, flags = 0 '\0', vsm_size = 0 '\0', vsm_data = '\0' }

This would seem to indicate that message has already been freed, possibly
by Python. However, what I'm wondering about is:

  If it fails on line 172, how did it ever get past lines 165/169?

This is on an 8-core machine so there may be something more subtle going
on.

Martin, what do you think? I will continue to investigate and update this
thread with my findings.

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

Reply via email to