1
votes

when we send bad data into zmq socket, I/O thread raises exception and process gets killed. Call stack of crash is as below

00 KERNELBASE!RaiseException+0x68
01 zmq::zmq_abort(char * errmsg_ = )+0x21 [objdir-windows-msvc-14.0.x86_64\build\libzmq\src\err.cpp @ 89]
02 zmq::tcp_read(unsigned int64 s_ = , void * data_ = , unsigned int64 size_ = )+0xa9 [objdir-windows-msvc-14.0.x86_64\build\libzmq\src\tcp.cpp @ 276]
03 zmq::stream_engine_t::in_event(void)+0x132 [objdir-windows-msvc-14.0.x86_64\build\libzmq\src\stream_engine.cpp @ 318]
04 zmq::select_t::trigger_events(class std::vector > * fd_entries_ = 0x0000019d323400c8, struct zmq::select_t::fds_set_t * local_fds_set_ = 0x0000006fe3f9fb90, int event_count_ = 0n2)+0x74 [objdir-windows-msvc-14.0.x86_64\build\libzmq\src\select.cpp @ 122]
05 zmq::select_t::select_family_entry(struct zmq::select_t::family_entry_t * family_entry_ = 0x0000019d323400c8, int max_fd_ = 0n0, bool use_timeout_ = <Value unavailable error>, struct timeval * tv_ = 0x0000006fe3fffc98)+0xe9 [objdir-windows-msvc-14.0.x86_64\build\libzmq\src\select.cpp @ 404] 06 zmq::select_t::loop(void)+0x352 [objdir-windows-msvc-14.0.x86_64\build\libzmq\src\select.cpp @ 360]
07 thread_routine(void * arg_ = )+0xd [objdir-windows-msvc-14.0.x86_64\build\libzmq\src\thread.cpp @ 47]
08 invoke_thread_procedure+0xe (Inline Function @ 00007ff7`50b99cf9) [d:\th\minkernel\crts\ucrt\src\appcrt\startup\thread.cpp @ 91]

Can anyone please help how to catch this exception ?

1

1 Answers

0
votes

In an effort to help you, although there are too few details to actually answer properly:

From https://github.com/zeromq/libzmq/blob/master/src/tcp.cpp

int zmq::tcp_read (fd_t s_, void *data_, size_t size_)
{
#ifdef ZMQ_HAVE_WINDOWS

const int rc =
  recv (s_, static_cast<char *> (data_), static_cast<int> (size_), 0);

//  If not a single byte can be read from the socket in non-blocking mode
//  we'll get an error (this may happen during the speculative read).
if (rc == SOCKET_ERROR) {
    const int last_error = WSAGetLastError ();
    if (last_error == WSAEWOULDBLOCK) {
        errno = EAGAIN;
    } else {
        wsa_assert (
          last_error == WSAENETDOWN || last_error == WSAENETRESET
          || last_error == WSAECONNABORTED || last_error == WSAETIMEDOUT
          || last_error == WSAECONNRESET || last_error == WSAECONNREFUSED
          || last_error == WSAENOTCONN);
        errno = wsa_error_to_errno (last_error);
    }
}
return rc == SOCKET_ERROR ? -1 : rc;
#else

Clearly the stack trace shows an abort so I expect this is from the assert which then calls abort or raiseexception in windows :

https://github.com/zeromq/libzmq/blob/master/src/err.cpp

So your best bet is to look into whether the connections was made and open , whether it had been closed, or any of the basic issues the assert checks for. If it is bad data then probably the connection was dropped by the receiver because it was an invalid message to ZMQ?

Anyway good luck and you need to post more than this to get better responses - what is the receiver like, what are you sending and what are you actually expecting to happen....