From ee9c0919e2921b7a0bf72d3ec80d4597bdb2b503 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Sun, 15 Jan 2023 22:08:55 +0000 Subject: [PATCH 1/4] Problem: address sanitizer complains about uninitialised func pointer Solution: just call the function directly --- src/raw_engine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/raw_engine.cpp b/src/raw_engine.cpp index 5910cd99..3eac5871 100644 --- a/src/raw_engine.cpp +++ b/src/raw_engine.cpp @@ -124,7 +124,7 @@ void zmq::raw_engine_t::error (error_reason_t reason_) // so that it knows the peer has been disconnected. msg_t terminator; terminator.init (); - (this->*_process_msg) (&terminator); + push_raw_msg_to_session (&terminator); terminator.close (); } stream_engine_base_t::error (reason_); From 117cbe690cd114777588c05ca62b39e6ef034dc1 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Sun, 15 Jan 2023 22:12:26 +0000 Subject: [PATCH 2/4] Problem: buffer overflow in new test case Solution: fix it --- tests/test_pubsub_topics_count.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_pubsub_topics_count.cpp b/tests/test_pubsub_topics_count.cpp index f4fdbcc0..5f6d9ecf 100644 --- a/tests/test_pubsub_topics_count.cpp +++ b/tests/test_pubsub_topics_count.cpp @@ -126,11 +126,11 @@ void test_nested_topic_prefixes () // Subscribe to other 3 (nested) topics TEST_ASSERT_SUCCESS_ERRNO ( - zmq_setsockopt (subscriber, ZMQ_SUBSCRIBE, "xyz", strlen ("a"))); + zmq_setsockopt (subscriber, ZMQ_SUBSCRIBE, "xyz", strlen ("xyz"))); TEST_ASSERT_SUCCESS_ERRNO ( - zmq_setsockopt (subscriber, ZMQ_SUBSCRIBE, "xy", strlen ("ab"))); + zmq_setsockopt (subscriber, ZMQ_SUBSCRIBE, "xy", strlen ("xy"))); TEST_ASSERT_SUCCESS_ERRNO ( - zmq_setsockopt (subscriber, ZMQ_SUBSCRIBE, "x", strlen ("abc"))); + zmq_setsockopt (subscriber, ZMQ_SUBSCRIBE, "x", strlen ("x"))); TEST_ASSERT_EQUAL_INT (get_subscription_count (subscriber), 6); TEST_ASSERT_EQUAL_INT (get_subscription_count (publisher), 6); From 7e0fdd82dedb22e5ae81d5e07209d753451329fc Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Mon, 16 Jan 2023 00:05:52 +0000 Subject: [PATCH 3/4] Problem: test_zmq_ppol_signals uses fixed TCP port Solution: use random one to avoid random failures --- tests/test_zmq_ppoll_signals.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/test_zmq_ppoll_signals.cpp b/tests/test_zmq_ppoll_signals.cpp index 44d90b0b..c0b5fe9e 100644 --- a/tests/test_zmq_ppoll_signals.cpp +++ b/tests/test_zmq_ppoll_signals.cpp @@ -73,7 +73,17 @@ void recv_string_expect_success_or_eagain (void *socket_, void test_ppoll_signals () { #ifdef ZMQ_HAVE_PPOLL + size_t len = MAX_SOCKET_STRING; + char my_endpoint[MAX_SOCKET_STRING]; pid_t child_pid; + + /* Get a random TCP port first */ + setup_test_context (); + void *sb = test_context_socket (ZMQ_REP); + bind_loopback (sb, 0, my_endpoint, len); + test_context_socket_close (sb); + teardown_test_context (); + do { child_pid = fork (); } while (child_pid == -1); // retry if fork fails @@ -85,7 +95,7 @@ void test_ppoll_signals () int recv_timeout = 5000; TEST_ASSERT_SUCCESS_ERRNO (zmq_setsockopt ( socket, ZMQ_RCVTIMEO, &recv_timeout, sizeof (recv_timeout))); - TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (socket, "tcp://*:6660")); + TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (socket, my_endpoint)); // bind is on the master process to avoid zombie children to hold on to binds // first send a test message to check whether the signal mask is setup in the child process @@ -139,8 +149,7 @@ void test_ppoll_signals () TEST_ASSERT_SUCCESS_ERRNO (sigaction (SIGTERM, &sa, NULL)); void *socket = test_context_socket (ZMQ_REP); - TEST_ASSERT_SUCCESS_ERRNO ( - zmq_connect (socket, "tcp://127.0.0.1:6660")); + TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (socket, my_endpoint)); zmq_pollitem_t pollitems[] = { {socket, 0, ZMQ_POLLIN, 0}, From a820627f55043a6f7d2dcb14e305b7302ab9038b Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Mon, 16 Jan 2023 00:09:02 +0000 Subject: [PATCH 4/4] Problem: test_zmq_ppoll_signals does not cleanup context Solution: do it, to avoid false positive in valgrind --- tests/test_zmq_ppoll_signals.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_zmq_ppoll_signals.cpp b/tests/test_zmq_ppoll_signals.cpp index c0b5fe9e..255734a6 100644 --- a/tests/test_zmq_ppoll_signals.cpp +++ b/tests/test_zmq_ppoll_signals.cpp @@ -112,6 +112,7 @@ void test_ppoll_signals () // finish test_context_socket_close (socket); + teardown_test_context (); // wait for child int status = 0; @@ -176,6 +177,7 @@ void test_ppoll_signals () // wait before closing socket, so that parent has time to receive sleep (1); test_context_socket_close (socket); + teardown_test_context (); _Exit (0); } #else