-
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
Unpredictable hanging on zmq_recv() with timeout on IOS 10.3. ( Xcode 8.3.1 is used) #2537
Comments
That does seem a bit weird, to have a function that errors out if not using _REALTIME but then calling it with something else, but it was refactored a few times so maybe that's why Let's start with the simple fix to get past the hang, could you please send a PR? Please also include the unit test Then, what we really want is the monotonic clock since it's measuring time elapsed, and realtime can jump backwards @evoskuil @robertcastle @azawawi can we do CLOCK_MONOTONIC on OSX? That code was added by a8f11b3 and modified by 0dfb32a and bf6d8a5 |
iOS 9 is affected. Please take a look at azawawi/SwiftyZeroMQ#14. |
Why is the Wall clock used there? CALENDAR_CLOCK should be changed to SYSTEM_CLOCK or changes from ntpd could have interesting outcomes.. |
@Asmod4n The clock choice is parameterized, but I failed to pass on the parameter to |
Could you please send a PR to fix it? |
@bluca done, tests passed locally with the changes. |
@cybermag please try again from latest master |
I have checked the fixes. All is ok in master branch. |
Thanks a lot! |
It will be in the next stable release, 4.2.3 |
Hello! I am using ZeroMQ 4.2.2 for my IOS project and faced with the hanging issue when
code calls zmq_recv() with some defined timeout. To exclude developer errors I have reproduced issue using test_timeio from official tests.
You can find the code of the test below, I have marked the line on which test freezes with
// this hangs comment.
I have debugged the code related to zmq_recv() and I have found that problem in a piece of code inside function int zmq::socket_base_t::recv (msg_t *msg_, int flags_)
In some case the while(true) loop never breaks.
I have logged end, timeout and clock.now_ms() value and have discoverd that value of clock.now_ms() sometimes is not changed, it always returns the same value.
The root of the problem in rdtsc() function.
as ZMQ_HAVE_OSX define is set, rtdsc() calls function alt_clock_gettime()
as clock_id == CLOCK_MONOTONIC the function returns -1 with errno = EINVAL.
The return value of alt_clock_gettime() is not checked, so ts struct will be filled by garbage which leads to unpredictable issues on recv.
I have changed the code to use
alt_clock_gettime (CLOCK_REALTIME, &ts);
instead of
alt_clock_gettime (CLOCK_MONOTONIC, &ts);
and this worked for me, but I am not sure that such fix is correct.
Could you please advice if such fix is correct?
The text was updated successfully, but these errors were encountered: