zeromq在I / O线程中引发异常

时间:2018-09-28 18:35:22

标签: c++ zeromq

当我们将不良数据发送到zmq套接字时,I / O线程引发异常并杀死进程。 崩溃的调用堆栈如下

  

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(类std :: vector> * fd_entries_ = 0x0000019d 323400c8, struct zmq::select_t::fds_set_t * local_fds_set_ = 0x0000006f e3f9fb90,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(结构zmq :: select_t :: family_entry_t * family_entry_ = 0x0000019d 323400c8, int max_fd_ = 0n0, bool use_timeout_ = <Value unavailable error>, struct timeval * tv_ = 0x0000006f e3fffc98)+ 0xe9 [objdir-windows-msvc-14.0.x86_c \ pp \ build \ libzmq \ src \ select。 @ 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(内联函数@ 00007ff7`50b99cf9)[d:\ th \ minkernel \ crts \ ucrt \ src \ appcrt \ startup \ thread.cpp @ 91]

任何人都可以帮助如何捕获此异常吗?

1 个答案:

答案 0 :(得分:0)

尽力为您提供帮助,尽管很少有细节可以正确回答:

来自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

很明显,堆栈跟踪显示了异常中止,所以我希望这是来自于在Windows中调用异常中止或raiseexception的断言:

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

因此,最好的选择是检查是否已建立并打开连接,是否已关闭连接或assert检查的任何基本问题。如果数据不好,则接收方可能会断开连接,因为这是发给ZMQ的无效消息?

无论如何,祝您好运,您需要发布更多信息才能获得更好的响应-接收者是什么样的,您发送的是什么以及您实际期望发生的事情。...