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

zmq connect aborts intermittently #2358

Closed
rabrahamkns opened this issue Mar 1, 2017 · 5 comments
Closed

zmq connect aborts intermittently #2358

rabrahamkns opened this issue Mar 1, 2017 · 5 comments

Comments

@rabrahamkns
Copy link

rabrahamkns commented Mar 1, 2017

Using libzmq 4.1.5, built with VS2010, win32, debug.
To reproduce:
My code creates a zmq socket and calls connect(). No Server is running.
The host address passed to connect is something like: "tcp://localhost:5111"
It aborts intermittently.
zmq::signaler_t::send() returns -1.

Call stack:


                _RaiseException@16() + 0x52 bytes        
               zmq::zmq_abort(const char * errmsg_=0x050c030c) Line 80 + 0x15 bytes              C++
>             zmq::signaler_t::send() Line 182 + 0x49 bytes     C++
               zmq::mailbox_t::send(const zmq::command_t & cmd_={...}) Line 66       C++
               zmq::ctx_t::send_command(unsigned int tid_=3, const zmq::command_t & command_={...}) Line 372  C++
               zmq::object_t::send_command(zmq::command_t & cmd_={...}) Line 436            C++
               zmq::object_t::send_own(zmq::own_t * destination_=0x1ceedf88, zmq::own_t * object_=0x3f8a7cc0) Line 222         C++
               zmq::own_t::launch_child(zmq::own_t * object_=0x3f8a7cc0) Line 90   C++
               zmq::socket_base_t::add_endpoint(const char * addr_=0x3f534430, zmq::own_t * endpoint_=0x3f8a7cc0, zmq::pipe_t * pipe=0x408e6558) Line 722            C++
               zmq::socket_base_t::connect(const char * addr_=0x3f534430) Line 715 C++
               zmq_connect(void * s_=0x1ceedf88, const char * addr_=0x3f534430) Line 316 + 0xc bytes           C++
               zmq::socket_t::connect(const char * addr_=0x3f534430) Line 581 + 0x12 bytes  C++
               ZmqClient::connectSession(IDvzTransportSessionCallback * cb=0x00000000) Line 76       C++
               CGSUCDatavizHelper::_StartDatavizTransport(IDvzTransport * & p_rTransportType=0x41702f00, wchar_t * p_sSessionId=0x0186e5b0) Line 320 + 0x17 bytes             C++
               CGSUCDatavizHelper::StartAllDatavizServices() Line 240 + 0x11 bytes      C++
               CMFEXMainApplication::_InitInstance(void * p_pLargeMemoryBlock=0x41d70000) Line 283 + 0x8 bytes                C++
               CMFEXMainApplication::InitInstance() Line 175 + 0xc bytes          C++
               AfxWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, wchar_t * lpCmdLine=0x00020c1a, int nCmdShow=1) Line 37 + 0xd bytes               C++
               wWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, wchar_t * lpCmdLine=0x00020c1a, int nCmdShow=1) Line 26           C++
               __tmainCRTStartup() Line 547 + 0x2c bytes          C
               wWinMainCRTStartup() Line 371               C
               _BaseProcessStart@4() + 0x23 bytes      

The sockets are dcreated and connected() in the main thread.

@rabrahamkns rabrahamkns changed the title zmq connect crashes intermittntly zmq connect crashes intermittently Mar 1, 2017
@rabrahamkns rabrahamkns changed the title zmq connect crashes intermittently zmq connect aborts intermittently Mar 1, 2017
@bluca
Copy link
Member

bluca commented Mar 2, 2017

Have you tried the latest stable release, 4.2.2? Or building from the master branch?

@rabrahamkns
Copy link
Author

rabrahamkns commented Mar 3, 2017

@bluca Building now 4.2.1, will update with the results. Also, I think this is related to this:
#2360
So I will try that too.
Thanks!

@rabrahamkns
Copy link
Author

rabrahamkns commented Mar 10, 2017

@bluca I can confirm this is fixed by #2360, we took our existing 4.1.5 code, made the changes @nexcvon made, rebuilt, and ran our program multiple times.
signaler_t::send() does not abort intermittently anymore. Tested on Windows XP 32 bit. Built with VS2010.
Thanks
Ronny

These 3 lines:

int nbytes = ::send (w, (char*) &dummy, sizeof (dummy), 0);
wsa_assert (nbytes != SOCKET_ERROR);
zmq_assert (nbytes == sizeof (dummy));

were replaced with these:

while (true) {
        int nbytes = ::send (w, (char*) &dummy, sizeof (dummy), 0);
        if (unlikely (nbytes == SOCKET_ERROR))
            continue;
        zmq_assert (nbytes == sizeof (dummy));
        break;
    }

@bluca
Copy link
Member

bluca commented Mar 10, 2017

Great, thanks for confirming

@rabrahamkns
Copy link
Author

Also I can confirm this was also tested for the additional line of code added in #2362 (to prevent send() from looping forever):
wsa_assert (nbytes != SOCKET_ERROR);
Again - tested on Windows XP 32 bit. Built with VS2010.

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

2 participants