qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject qpid-proton git commit: PROTON-1773: [epoll-proactor] Invalid read in pn_proactor_disconnect
Date Mon, 26 Feb 2018 23:05:46 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/master 13fb06ed5 -> 9a2954a94


PROTON-1773: [epoll-proactor] Invalid read in pn_proactor_disconnect

The problem was a loop using a pointer to memory that could be deleted while the
loop was running.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/9a2954a9
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/9a2954a9
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/9a2954a9

Branch: refs/heads/master
Commit: 9a2954a94aa795ceceabacb7a717dcb8f9bf15f3
Parents: 13fb06e
Author: Alan Conway <aconway@redhat.com>
Authored: Mon Feb 26 17:51:37 2018 -0500
Committer: Alan Conway <aconway@redhat.com>
Committed: Mon Feb 26 17:51:37 2018 -0500

----------------------------------------------------------------------
 proton-c/bindings/cpp/src/container_test.cpp | 7 +++++++
 proton-c/src/proactor/epoll.c                | 5 ++++-
 2 files changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9a2954a9/proton-c/bindings/cpp/src/container_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/container_test.cpp b/proton-c/bindings/cpp/src/container_test.cpp
index 3afb340..8f9075f 100644
--- a/proton-c/bindings/cpp/src/container_test.cpp
+++ b/proton-c/bindings/cpp/src/container_test.cpp
@@ -302,6 +302,7 @@ class test_mt_handler : public proton::messaging_handler {
     std::mutex lock_;
     std::condition_variable cond_;
     std::string str_;
+    proton::error_condition err_;
 
     void set(const std::string& s) {
         std::lock_guard<std::mutex> l(lock_);
@@ -317,8 +318,12 @@ class test_mt_handler : public proton::messaging_handler {
         return s;
     }
 
+    proton::error_condition error() const { return err_; }
     void on_container_start(proton::container &) PN_CPP_OVERRIDE { set("start"); }
     void on_connection_open(proton::connection &) PN_CPP_OVERRIDE { set("open"); }
+
+    // Catch errors and save.
+    void on_error(const proton::error_condition& e) PN_CPP_OVERRIDE { err_ = e; }
 };
 
 class container_runner {
@@ -339,6 +344,7 @@ int test_container_mt_stop_empty() {
     ASSERT_EQUAL("start", th.wait());
     c.stop();
     t.join();
+    ASSERT_EQUAL("", th.error().name());
     return 0;
 }
 
@@ -354,6 +360,7 @@ int test_container_mt_stop() {
     ASSERT_EQUAL("open", th.wait());
     c.stop();
     t.join();
+    // It is possible to get sporadic connection errors from this test depending on timing
of stop()
     return 0;
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9a2954a9/proton-c/src/proactor/epoll.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/epoll.c b/proton-c/src/proactor/epoll.c
index 4ad2506..efe2a82 100644
--- a/proton-c/src/proactor/epoll.c
+++ b/proton-c/src/proactor/epoll.c
@@ -2125,7 +2125,10 @@ void pn_proactor_disconnect(pn_proactor_t *p, pn_condition_t *cond)
{
   }
 
   // Second pass: different locking, close the pcontexts, free them if !disconnect_ops
-  for (ctx = disconnecting_pcontexts; ctx; ctx = ctx->next) {
+  pcontext_t *next = disconnecting_pcontexts;
+  while (next) {
+    ctx = next;
+    next = ctx->next;           /* Save next pointer in case we free ctx */
     bool do_free = false;
     bool ctx_notify = true;
     pmutex *ctx_mutex = NULL;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message