Hello,

I am using proton cpp version 0.27.0.
I have a random crash when calling stop on the container after closing the
connection.
Please find the attached the code and the stack.

In the doc, it is said that the container object is thread safe but
apparently there is flaw...

Can you please advise?

Do you need me to create a Jira issue?


Best regards,

Rabih
#include <proton/connection.hpp>
#include <proton/container.hpp>
#include <proton/messaging_handler.hpp>

#include <iostream>
#include <thread>

class handler : public proton::messaging_handler {
public:
   handler(const std::string& u) 
   : m_url(u), m_work(0) 
   {}

   proton::work_queue* getWorkQueue() {
      if (!m_work)
         m_workProm.get_future().get();

      return m_work;
   }

   std::promise<void> m_closeProm;

private:
   void on_connection_open(proton::connection& c)override{
       m_work = &c.work_queue();
       m_workProm.set_value();
   }

   void on_connection_close(proton::connection&)override{
      m_closeProm.set_value();
   }

   std::string m_url;
   proton::work_queue* m_work;
   std::promise<void> m_workProm;
};

int main {
   try {
      std::string url("//127.0.0.1:5672");
      handler h(url);
      proton::container c(h);
      std::thread clientThread([&]() {
         try
         {
            c.run();
         }
         catch (const std::exception& e) {
            std::cerr << "Broker threw exception: " << e.what() << std::endl;
         }});

      proton::connection con = c.connect(url);
      h.getWorkQueue()->add([&]() {con.close(); });
      h.m_closeProm.get_future().get();
      c.stop();

      if (clientThread.joinable())
      {
         clientThread.join();
      }
   }
   catch (std::exception& e) {
      std::cerr << e.what() << std::endl;
   }
   return 0;
}
#0  pn_transport_tail_closed (transport=0x0) at 
/proton-workspace/qpid-proton-0.27.0/c/src/core/transport.c:3102
#1  0x00007ff91c4450e9 in pconnection_rclosed (pc=0x183d790, events=Unhandled 
dwarf expression opcode 0xf3) at 
/proton-workspace/qpid-proton-0.27.0/c/src/proactor/epoll.c:962
#2  pconnection_process (pc=0x183d790, events=Unhandled dwarf expression opcode 
0xf3) at /proton-workspace/qpid-proton-0.27.0/c/src/proactor/epoll.c:1164
#3  0x00007ff91c445cd2 in process_inbound_wake (p=0x1831ce0, can_block=true) at 
/proton-workspace/qpid-proton-0.27.0/c/src/proactor/epoll.c:2092
#4  proactor_do_epoll (p=0x1831ce0, can_block=true) at 
/proton-workspace/qpid-proton-0.27.0/c/src/proactor/epoll.c:2129
#5  0x00007ff91d1acbec in proton::container::impl::thread (this=0x1830520) at 
/proton-workspace/qpid-proton-0.27.0/cpp/src/proactor_container_impl.cpp:736
#6  0x00007ff91d1ad220 in proton::container::impl::run (this=0x1830520, 
threads=<value optimized out>) at 
/proton-workspace/qpid-proton-0.27.0/cpp/src/proactor_container_impl.cpp:788
#7  0x000000000048114a in 
ContainerTest_rabih_Test::TestBody()::{lambda()#1}::operator()() const ()
#8  0x0000000000482e42 in void 
std::_Bind_simple<ContainerTest_rabih_Test::TestBody()::{lambda()#1} 
()()>::_M_invoke<>(std::_Index_tuple<>) ()
#9  0x0000000000482d87 in 
std::_Bind_simple<ContainerTest_rabih_Test::TestBody()::{lambda()#1} 
()()>::operator()() ()
#10 0x0000000000482d04 in 
std::thread::_Impl<std::_Bind_simple<ContainerTest_rabih_Test::TestBody()::{lambda()#1}
 ()()> >::_M_run() ()
#11 0x00007ff91cf2d470 in ?? () from /usr/lib64/libstdc++.so.6
#12 0x00007ff91d641851 in start_thread () from /lib64/libpthread.so.0
#13 0x00007ff91c73290d in clone () from /lib64/libc.so.6
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@qpid.apache.org
For additional commands, e-mail: users-h...@qpid.apache.org

Reply via email to