[zeromq-dev] ZMQ Crash from unknown DNS name

David Kantowitz dkantowitz at gmail.com
Wed Jan 26 19:53:13 CET 2011


Hello Joshua,


Date: Tue, 25 Jan 2011 17:50:09 -0500

From: Joshua Foster <jhawk28 at gmail.com>

Subject: [zeromq-dev] ZMQ Crash from unknown DNS name


> I am trying to setup a service with ZeroMQ that subscribes to a TCP

endpoint that doesn't exist when the computer starts up. I am using the

computer name as I don't know what the DHCP address will be. ZMQ crashes

with the following assertion: Assertion failed: rc == 0

(..\..\..\src\zmq_connecter.cpp:46)


I had similar problems.  I get an assertion on an i/o thread anytime I
called connect() to a malformed or unresolvable address, and bind() to an
unknown or malformed interface.

My quick fix was to check the address and interface in socket_base::bind()
and socket_base::connect().  Obviously for connect() this will put the
delays to do name resolution in the application thread instead of the i/o
thread.  Also, since I don't keep the resolved name, the name gets looked-up
a second time in the i/o thread.  For my application both of these are
acceptable.

I've pasted my change below in case you want to do something similar.

Best regards,
David Kantowitz


=== (+19,-1) src/socket_base.cpp ===
@@ -278,6 +278,15 @@
     if (rc != 0)
         return -1;

+ // Check validity of address
+ if (protocol == "tcp" || protocol == "pgm" || protocol == "epgm") {
+ sockaddr_storage addr;
+ socklen_t len;
+        int rc =  resolve_ip_interface (&addr, &len, address.c_str());
+ if (rc != 0)
+ return -1;
+ }
+
     if (protocol == "inproc" || protocol == "sys")
         return register_endpoint (addr_, this);

@@ -340,6 +349,15 @@
     if (rc != 0)
         return -1;

+ // Check validity of address
+ if (protocol == "tcp" || protocol == "pgm" || protocol == "epgm") {
+ sockaddr_storage addr;
+ socklen_t len;
+        int rc =  resolve_ip_hostname (&addr, &len, address.c_str());
+ if (rc != 0)
+ return -1;
+ }
+
     if (protocol == "inproc" || protocol == "sys") {

         //  TODO: inproc connect is specific with respect to creating pipes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110126/1c3fb5fd/attachment.htm>


More information about the zeromq-dev mailing list