Sending data to the same pair socket in multi threads may cause aborting in msg_t::size()

Description

I used router-dealer pattern in my application. In order to send and receive data from the router socket in the same thread, I used the pairs to transfer message. I did't realize that the pipe_t::write was not thread safe, because queue.back() and queue.push() in ypipe_t::write() are both dependent on the same member "back_pos". In multi-threads called, it would push an empty msg into queue that caused aborting at "zmq_assert(check())" in zmq::msg_t::size().
It was my mistake to send data to the same pair socket in multi-threads. But, I was wondering that the monitor_event in socket_base also used the same pair to send events in multi-threads at the same time.
I added log in socket_base.cpp and modified the test_monitor.cpp in tests folder and made check. The log(see attached file) shows that what I concerned is the truth.
Am I alarmist?

Environment

ubuntu 12.10 64bit

Attachments

1
  • 19 Jun 2014, 01:31 PM

Activity

Show:
starcheng
updated the DescriptionJune 19, 2014 at 1:34 PM
I used router-dealer pattern in my application. In order to send and receive data from the router socket, I used the pairs to transfer message. I did't realize that the pipe_t::write was not thread safe, because queue.back() and queue.push() in ypipe_t::write() are both dependent on the same member "back_pos". In multi-threads called, it would push an empty msg into queue that caused aborting at "zmq_assert(check())" in zmq::msg_t::size(). It was my mistake to send data to the same pair socket in multi-threads. But, I was wondering that the monitor_event in socket_base also used the same pair to send events in multi-threads at the same time. I added log in socket_base.cpp and modified the test_monitor.cpp in tests folder and made check. The log(see attached file) shows that what I concerned is the truth. Am I alarmist?
I used router-dealer pattern in my application. In order to send and receive data from the router socket in the same thread, I used the pairs to transfer message. I did't realize that the pipe_t::write was not thread safe, because queue.back() and queue.push() in ypipe_t::write() are both dependent on the same member "back_pos". In multi-threads called, it would push an empty msg into queue that caused aborting at "zmq_assert(check())" in zmq::msg_t::size(). It was my mistake to send data to the same pair socket in multi-threads. But, I was wondering that the monitor_event in socket_base also used the same pair to send events in multi-threads at the same time. I added log in socket_base.cpp and modified the test_monitor.cpp in tests folder and made check. The log(see attached file) shows that what I concerned is the truth. Am I alarmist?
starcheng
created the IssueJune 19, 2014 at 1:31 PM

Assignee

Reporter

Components

Affects versions

Priority

Created June 19, 2014 at 1:31 PM
Updated June 19, 2014 at 1:34 PM