Uploaded image for project: 'Qpid'
  1. Qpid
  2. QPID-8246

File leak in heartbeat algorithm

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: qpid-cpp-1.38.0
    • Fix Version/s: None
    • Component/s: C++ Client
    • Labels:
      None
    • Environment:

      SO: Debian GNU/Linux 9 (stretch)

       

      Description

      The heartbeat option is causing file leak when the interface is down or the address is unreachable.

      I've programmed a little test client to reproduce the error, this client source is on the attachments, to check the opened files of the process i've used the following bash script:

      while :; do lsof -u root | grep $(pgrep -f ./client) | wc -l; sleep 1; done

      The client if compiled with the following syntax:

      g++ client.c -o client -lqpidmessaging -lqpidtypes -lpthread

      Valgrind command was called with the following parameters:

       

      valgrind --tool=memcheck --track-fds=yes --leak-check=full --read-var-info=yes --show-reachable=yes --track-origins=yes ./client > valgrind-output.log 2>&1
      

      The valgrind is initialized with the interface up and working, after some time, the interface is disabled and the leak  begin.

      If the application runs for long time, this file leak turns into a crash on the program, due to the linux max open files, even if the connection still comes back the files continue opened.

      Resumed valgrind output for this issue:

      ==26937== FILE DESCRIPTORS: 17 open at exit.
      ==26937== Open AF_INET socket 16: <unbound> <-> unbound
      ==26937== at 0x4C19001: socket (socket.c:32)
      ==26937== by 0x4EEA04F: qpid::sys::BSDSocket::createSocket(qpid::sys::SocketAddress const&) const (in /usr/local/lib/libqpidcommon.so.2.0.0)
      ==26937== by 0x4EEA521: qpid::sys::BSDSocket::connect(qpid::sys::SocketAddress const&) const (in /usr/local/lib/libqpidcommon.so.2.0.0)
      ==26937== by 0x4ECC233: qpid::sys::posix::AsynchConnector::AsynchConnector(qpid::sys::Socket const&, std::_cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::function1<void, qpid::sys::Socket const&>, boost::function3<void, qpid::sys::Socket const&, int, std::_cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&>) (in /usr/local/lib/libqpidcommon.so.2.0.0)
      ==26937== by 0x4ECC8D7: qpid::sys::AsynchConnector::create(qpid::sys::Socket const&, std::_cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::function1<void, qpid::sys::Socket const&>, boost::function3<void, qpid::sys::Socket const&, int, std::_cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&>) (in /usr/local/lib/libqpidcommon.so.2.0.0)
      ==26937== by 0x4D7FF74: qpid::client::TCPConnector::connect(std::_cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::_cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (in /usr/local/lib/libqpidclient.so.2.0.0)
      ==26937== by 0x4D37C06: qpid::client::ConnectionImpl::open() (in /usr/local/lib/libqpidclient.so.2.0.0)
      ==26937== by 0x4D272CF: qpid::client::Connection::open(qpid::client::ConnectionSettings const&) (in /usr/local/lib/libqpidclient.so.2.0.0)
      ==26937== by 0x4D27DF0: qpid::client::Connection::open(qpid::Url const&, qpid::client::ConnectionSettings const&) (in /usr/local/lib/libqpidclient.so.2.0.0)
      ==26937== by 0x48898F6: qpid::client::amqp0_10::ConnectionImpl::tryConnect() (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==26937== by 0x488B468: qpid::client::amqp0_10::ConnectionImpl::connect(qpid::sys::AbsTime const&) (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==26937== by 0x488D137: qpid::client::amqp0_10::ConnectionImpl::open() (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==26937==

        Attachments

        1. valgrind-output.log
          1.30 MB
          Lucas Guilherme Hübner
        2. client.c
          3 kB
          Lucas Guilherme Hübner

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              lucas.hubner Lucas Guilherme Hübner
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: