Skip to content
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

Crash when using zpoller_wait #2044

Closed
AnitaTang opened this issue Jun 19, 2016 · 13 comments
Closed

Crash when using zpoller_wait #2044

AnitaTang opened this issue Jun 19, 2016 · 13 comments

Comments

@AnitaTang
Copy link

Hi,I have defined m_poller using zpoller_new with many arguments and then this m_poller is used in zpoller_wait with setting timeout -1, it will crash if two sockets are receiving messages. I'm not sure of the reason. Look forward to your help.

@somdoron
Copy link
Member

Can you include a code that reproduce?
On Jun 19, 2016 17:30, "AnitaTang" notifications@github.com wrote:

Hi,I have defined m_poller using zpoller_new with many arguments and then
this m_poller is used in zpoller_wait with setting timeout -1, it will
crash if two sockets are receiving messages. I'm not sure of the reason.
Look forward to your help.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#2044, or mute the thread
https://github.com/notifications/unsubscribe/AClv9n4TfwxABV65eHgjEWwLt1CrhR3Kks5qNVKEgaJpZM4I5LT6
.

@AnitaTang
Copy link
Author

Thanks for your reply, the code is as following:
m_poller = zpoller_new(m_sock_pull_lock, m_sock_pull_unlock, m_sock_pull_check,
m_sock_rep_dump, m_sock_rep_get, m_sock_rep_quit, m_sock_rep_modify, nullptr);
zsock_t *whichOne = (zsock_t *) zpoller_wait(m_poller, -1);
Two messages are sent to m_sock_rep_quit and m_sock_pull_lock simultaneously, the app will crash here according to the crash report.

@somdoron
Copy link
Member

Which libzmq version are you using?
can you attach the crash report?

@AnitaTang
Copy link
Author

Ok.Here is the crash report
#0 0x00007f1bb9ecc8a5 in raise () from /lib64/libc.so.6
#1 0x00007f1bb9ece085 in abort () from /lib64/libc.so.6
#2 0x00007f1bb9ec5a1e in __assert_fail_base () from /lib64/libc.so.6
#3 0x00007f1bb9ec5ae0 in __assert_fail () from /lib64/libc.so.6
#4 0x00000000009687b9 in zsock_vsend () at src/zsock.c:659
#5 0x0000000000968887 in zsock_send () at src/zsock.c:645
#6 0x00000000007c6fac in DataOperator::impl::deal_sock_unlock() ()
#7 0x00000000007c39ac in DataOperator::impl::Loop()::{lambda()#1}::operator()() const ()

@AnitaTang
Copy link
Author

And zmq version is 4.1.4 ,czmq version is 3.0.2. we make the files libczmq.a and libzmq.a out of source code by ourselves.

@somdoron
Copy link
Member

According to the crash report the exception is in zsock_send, it seems you have error with the picture or array. Can you include the send code?

@AnitaTang
Copy link
Author

AnitaTang commented Jun 25, 2016

Thanks again.Here is the send code。
send messages:

    {
    //Two threads keep sending these two messages
        zsock_t *m_sock_push_unlock = zsock_new_push_unlimited(PIPE_PROTOCAL_READY2RETURNDATA);
        zsock_t *m_sock_push_lock = zsock_new_push_unlimited(PIPE_PROTOCAL_READY2ACQUIREDATA);
        //pTask is a class instance
        zsock_send(m_sock_push_unlock, "p", pTask); 
        zsock_send(m_sock_push_lock, "p", pTask);
    }

    {//start to send quit message at some point
        zsock_t *sock_req_quit = zsock_new_req(PIPE_PROTOCAL_QUITER_DATAOPERATOR);
        uint8_t req(1), rep(2);
        zsock_recv(sock_req_quit, "1", &req);
        zsock_send(sock_req_quit, "1", rep);
        LOG4CPLUS_MACRO_FMT_BODY(Logger::getInstance(LOGGER_STATUS), INFO_LOG_LEVEL,"ending 1");//this log is in the log when crash happens
    }

receive messages:

while (true) {
    zsock_t *whichOne = (zsock_t *) zpoller_wait(m_poller, -1);
    if (whichOne == m_sock_pull_lock) {
        zsock_recv(m_sock_pull_unlock, "p", &pTask);
    }
    else if (whichOne == m_sock_pull_unlock) {
        zsock_recv(m_sock_pull_lock, "p", &pTask);
    }
    else if (whichOne == m_sock_rep_quit) {
        zsock_recv(m_sock_rep_quit, "1", &req);
        zsock_send(m_sock_rep_quit, "1", rep);
        LOG4CPLUS_MACRO_FMT_BODY(Logger::getInstance(LOGGER_STATUS), INFO_LOG_LEVEL,"ending 2");//this log is not in the log when crash happens
    }   
}

@AnitaTang
Copy link
Author

It seems that something wrong happens when zpoller_wait is accepting the quit message.

@somdoron
Copy link
Member

which one is the deal_sock_unlock method?

@AnitaTang
Copy link
Author

if (whichOne == m_sock_pull_lock) {
deal_sock_unlock();
}
and in void deal_sock_unlock(){ zsock_recv(m_sock_pull_unlock, "p", &pTask);...}

@somdoron
Copy link
Member

somdoron commented Jul 1, 2016

This is still unclean for me.

In the stacktrace deal_sock_unlock is calling zsock_send, but in your example the deal_sock_unlock is only calling zsock_recv. I think something is missing from your example.

I suspect it has nothing to do with poller and wrong picture to zsock_send, it will be great if you can attach the full code of deal_sock_unlock, as I don't think poller has nothing to do with it.

@AnitaTang
Copy link
Author

Sorry for the trouble, there's something wrong with my multi-thread code while using zmq .Thanks a lot again.

@bluca
Copy link
Member

bluca commented Jan 3, 2017

Closing since it was a problem in the application

@bluca bluca closed this as completed Jan 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants