-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comment to provoke review of suspect code #982
Conversation
@@ -116,7 +116,8 @@ int zmq::lb_t::sendpipe (msg_t *msg_, pipe_t **pipe_) | |||
more = msg_->flags () & msg_t::more? true: false; | |||
if (!more) { | |||
pipes [current]->flush (); | |||
current = (current + 1) % active; | |||
current = (current + 1) % active; // in zmq 3.x this causes crash if the last pipe is terminated beween the | |||
// the test for active == 0 at 109 and here as %(active==0) causes a crash. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A think we can safely assert that active is non zero here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Martin,
I do not know the zeromq code very well... and the current code not at all.
The question I raise is "Is 'active' modified and read in two different
threads?".
Because I am confident that in zeromq3-x it is modified in two threads and
a race to crash exists as a consequence.
On Fri, Apr 25, 2014 at 4:54 PM, Martin Hurton notifications@github.comwrote:
In src/lb.cpp:
@@ -116,7 +116,8 @@ int zmq::lb_t::sendpipe (msg_t msg, pipe_t *pipe)
more = msg_->flags () & msg_t::more? true: false;
if (!more) {
pipes [current]->flush ();
current = (current + 1) % active;
current = (current + 1) % active; // in zmq 3.x this causes crash if the last pipe is terminated beween the
// the test for active == 0 at 109 and here as %(active==0) causes a crash.
A think we can safely assert that active is non zero here.
—
Reply to this email directly or view it on GitHubhttps://github.com//pull/982/files#r12002719
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code should be executed only in one thread, provided the application does not invoke socket operation in two different threads. That's the assumption of the library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the threads involved here is the IO thread in the zmq context.
@daveab did you manage to provoke the crash in 3.x consistently? |
about 10 out of twenty runs of the test case. On Fri, Apr 25, 2014 at 5:19 PM, Pieter Hintjens
|
#0 zmq::lb_t::validate_thread (this=0x9efa80) at lb.cpp:185 As this stack shows.. zmq::lb_t::terminated() is called from the internal Simply adding the code to get the thread_id and compare with previously It is a very small target. Dave On Fri, Apr 25, 2014 at 5:25 PM, David Brown david.brown@datasift.comwrote:
|
Although this change would fix the race condition over changing active to zero it also implies its possible to do a flush on a pipe we have erased. |
I'm not sure what the conclusion was here, but as the pull request doesn't solve a clear issue afaics, I'm closing it. |
see the change I proposed for 3x.