[ 
https://issues.apache.org/jira/browse/QPID-8246?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17163716#comment-17163716
 ] 

Ravi trivedi commented on QPID-8246:
------------------------------------

Even I am facing this issue on 0.34 probably QPID-7355 also talks about FD 
leak. Issue occurs when a client tries to connect to a broker whose IP can not 
be reached. To produce the issue with the "client.cpp" attached here, choose an 
IP for which no route exists on the routing table ( not even default route ).

Valgrind seems to show leak in BSDSocket.cpp connect() method. to be precise, 
issue seems to be in the following if condition. It doesn't close the socket if 
error occurs. Adding close() inside if seems to be fixing the issue.

 

// TODO the correct thing to do here is loop on failure until you've used all 
the returned addresses
 if ((::connect(socket, getAddrInfo(addr).ai_addr, 
getAddrInfo(addr).ai_addrlen) < 0) &&
 (errno != EINPROGRESS)) {
 throw Exception(QPID_MSG(strError(errno) << ": " << peername));
 }

> File leak in heartbeat algorithm
> --------------------------------
>
>                 Key: QPID-8246
>                 URL: https://issues.apache.org/jira/browse/QPID-8246
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Client
>    Affects Versions: qpid-cpp-1.38.0
>         Environment: SO: Debian GNU/Linux 9 (stretch)
>  
>            Reporter: Lucas Guilherme Hübner
>            Priority: Major
>         Attachments: client.c, valgrind-output.log
>
>
> 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:
> {code:java}
> while :; do lsof -u root | grep $(pgrep -f ./client) | wc -l; sleep 1; 
> done{code}
> The client if compiled with the following syntax:
> {code:java}
> g++ client.c -o client -lqpidmessaging -lqpidtypes -lpthread{code}
> Valgrind command was called with the following parameters:
>  
> {code:java}
> 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
> {code}
> 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==



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to