From owner-freebsd-bugs Fri Sep 12 02:03:05 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id CAA19150 for bugs-outgoing; Fri, 12 Sep 1997 02:03:05 -0700 (PDT) Received: from citadel.cdsec.com (citadel.cdsec.com [192.96.22.18]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id CAA19126 for ; Fri, 12 Sep 1997 02:02:52 -0700 (PDT) Received: (from nobody@localhost) by citadel.cdsec.com (8.8.5/8.6.9) id LAA20455; Fri, 12 Sep 1997 11:07:03 +0200 (SAT) Received: by citadel via recvmail id 20453; Fri Sep 12 11:06:58 1997 by gram.cdsec.com (8.8.5/8.8.5) id KAA20043; Fri, 12 Sep 1997 10:40:11 +0200 (SAT) From: Graham Wheeler Message-Id: <199709120840.KAA20043@cdsec.com> Subject: Re: Memory leak in getservbyXXX? To: mike@smith.net.au (Mike Smith) Date: Fri, 12 Sep 1997 10:40:10 +0200 (SAT) Cc: freebsd-bugs@freebsd.org In-Reply-To: <199709120243.MAA00728@word.smith.net.au> from "Mike Smith" at Sep 12, 97 12:43:35 pm X-Mailer: ELM [version 2.4 PL25-h4.1] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > > In each case, while the location in our own code varies, the stack trace > > always ends in a call to getservbyname() or getservbyport(). These in turn > > are calling either malloc() or free(), which in turn seem to be calling > > fstat() (at least according to the stack backtrace). > > That's fairly odd; malloc()/free() do not call fstat(). Are you using > the system malloc() or the GNU version? Here are three sample core dumps: #0 0x52220 in fstat () #1 0x95000 in ?? () #2 0x5256e in free () #3 0x46312 in fclose () #4 0x334af in endservent () #5 0x2f84e in getservbyname () #6 0x253e0 in GetPort (protocol=6, service=0xbf510
) at service.cc:34 #7 0x25405 in GetTCPPort (service=0xbf510
) at service.cc:42 #8 0x1d136 in TCPGatewaySet::DestPort (this=0x683d0, n=4) at gateways.cc:39 #9 0x1d08d in GatewaySet::Match (this=0x683d0, n=4, cliaddr=0xefbfd824 "\n}\016\nÏD\211C", cliport=3088, dstaddr=0xefbfd828 "ÏD\211C", dstport=80) at gateways.cc:25 #10 0x1755d in AccessRuleSet::CheckGateways (this=0x68344, gateways=0x683d0, cliaddr=0xefbfd824 "\n}\016\nÏD\211C", cliport=3088, dstaddr=0xefbfd828 "ÏD\211C", dstport=80, user=0xefbfd86c "", group=0xefbfd82c "", identtypes=0xefbfd820) at access.cc:229 #11 0x17648 in AccessRuleSet::CheckTCPGateways (this=0x68344, cliaddr=0xefbfd824 "\n}\016\nÏD\211C", cliport=3088, dstaddr=0xefbfd828 "ÏD\211C", dstport=80, user=0xefbfd86c "", group=0xefbfd82c "", identtypes=0xefbfd820) at access.cc:255 #12 0x4fc4 in SessionGroup::AddOutgoingSession (this=0x67420, pkt=0x86640, queueit=0xefbfdbfc) at session.cc:1267 #13 0x588a in TCPSessionGroup::AddOutgoingSession (this=0x67420, pkt=0x86640, queueit=0xefbfdbfc) at session.cc:1501 #14 0x5e3f in SessionManager::FindInsideSession (this=0x67400, pkt=0x86640, queueit=0xefbfdbfc) at session.cc:1639 #15 0xa43e in Interface::GetSession (this=0x6b000, sm=0x67400, pkt=0x86640, to_inside=0, queueit=0xefbfdbfc) at iface.cc:405 #16 0xa817 in Interface::Gateway (this=0x6b000, other=0x6b100, sm=0x67400, to_inside=0) at iface.cc:468 #17 0x8314 in Gateway::HandleEvents (this=0x86600) at gateway.cc:209 #18 0x85b0 in Gateway::Run (this=0x86600) at gateway.cc:294 #19 0x1701 in main (argc=6, argv=0xefbfdce4) at cdsgw.cc:165 #0 0x51a60 in fstat () #1 0x63f54 in buffer () #2 0x51da2 in fstat () #3 0x524f6 in malloc () #4 0x50ba9 in __smakebuf () #5 0x461c0 in __srefill () #6 0x45b24 in fgets () #7 0x33535 in getservent () #8 0x2f7ed in getservbyname () #9 0x253e0 in GetPort (protocol=6, service=0x69510 "http\t\t70/udp\nrje\t\t77/tcp\t\tnetrjs\nfinger\t\t79/tcp\nhttp\t\t80/tcp\t\thttp\t# WorldWideWeb HTTP\nhttp\t\t80/udp\t\t\t# HyperText Transfer Protocol\nlink\t\t87/tcp\t\tttylink\n#kerberos\t88/tcp\t\tkrb5\t# Kerberos v5\n#kerberos"...) at service.cc:34 #10 0x25405 in GetTCPPort ( service=0x69510 "http\t\t70/udp\nrje\t\t77/tcp\t\tnetrjs\nfinger\t\t79/tcp\nhttp\t\t80/tcp\t\thttp\t# WorldWideWeb HTTP\nhttp\t\t80/udp\t\t\t# HyperText Transfer Protocol\nlink\t\t87/tcp\t\tttylink\n#kerberos\t88/tcp\t\tkrb5\t# Kerberos v5\n#kerberos"...) at service.cc:42 #11 0x1d136 in TCPGatewaySet::DestPort (this=0x683d0, n=4) at gateways.cc:39 #12 0x1d08d in GatewaySet::Match (this=0x683d0, n=4, cliaddr=0xefbfd824 "\n|\002\027Ä\aF\203", cliport=1725, dstaddr=0xefbfd828 "Ä\aF\203", dstport=80) at gateways.cc:25 #13 0x1755d in AccessRuleSet::CheckGateways (this=0x68344, gateways=0x683d0, cliaddr=0xefbfd824 "\n|\002\027Ä\aF\203", cliport=1725, dstaddr=0xefbfd828 "Ä\aF\203", dstport=80, user=0xefbfd86c "", group=0xefbfd82c "", identtypes=0xefbfd820) at access.cc:229 #14 0x17648 in AccessRuleSet::CheckTCPGateways (this=0x68344, cliaddr=0xefbfd824 "\n|\002\027Ä\aF\203", cliport=1725, dstaddr=0xefbfd828 "Ä\aF\203", dstport=80, user=0xefbfd86c "", group=0xefbfd82c "", identtypes=0xefbfd820) at access.cc:255 #15 0x4fc4 in SessionGroup::AddOutgoingSession (this=0x67420, pkt=0x86640, queueit=0xefbfdbfc) at session.cc:1267 #16 0x588a in TCPSessionGroup::AddOutgoingSession (this=0x67420, pkt=0x86640, queueit=0xefbfdbfc) at session.cc:1501 #17 0x5e3f in SessionManager::FindInsideSession (this=0x67400, pkt=0x86640, queueit=0xefbfdbfc) at session.cc:1639 #18 0xa43e in Interface::GetSession (this=0x6b000, sm=0x67400, pkt=0x86640, to_inside=0, queueit=0xefbfdbfc) at iface.cc:405 #19 0xa817 in Interface::Gateway (this=0x6b000, other=0x6b100, sm=0x67400, to_inside=0) at iface.cc:468 #20 0x8314 in Gateway::HandleEvents (this=0x86600) at gateway.cc:209 #21 0x85b0 in Gateway::Run (this=0x86600) at gateway.cc:294 #22 0x1701 in main (argc=6, argv=0xefbfdce4) at cdsgw.cc:165 #0 0x52220 in fstat () #1 0x83000 in ?? () #2 0x5256e in free () #3 0x46312 in fclose () #4 0x334af in endservent () #5 0x2f79a in getservbyport () #6 0x2581b in Service (protocol=17, port=0) at service.cc:257 #7 0x268e in TransportSession::ServiceName (this=0x6b300) at session.cc:360 #8 0x2dfd in UDPSession::ServiceName (this=0x6b300) at session.cc:527 #9 0x284e in TransportSession::Print (this=0x6b300, buf=0xefbfdac4 "\024", verbose=0) at session.cc:388 #10 0x23d7 in IPSession::Terminate (this=0x6b300) at session.cc:299 #11 0x2da7 in TransportSession::Terminate (this=0x6b300) at session.cc:515 #12 0x4c28 in SessionGroup::AgeSessions (this=0x67440) at session.cc:1195 #13 0x5d9c in SessionManager::AgeSessions (this=0x67400) at session.cc:1614 #14 0x83f5 in Gateway::HandleEvents (this=0x86600) at gateway.cc:227 #15 0x85b0 in Gateway::Run (this=0x86600) at gateway.cc:294 #16 0x1701 in main (argc=6, argv=0xefbfdcd4) at cdsgw.cc:165 -- Dr Graham Wheeler E-mail: gram@cdsec.com Citadel Data Security Phone: +27(21)23-6065/6/7 Internet/Intranet Network Specialists Mobile: +27(83)-253-9864 Firewalls/Virtual Private Networks Fax: +27(21)24-3656 Data Security Products WWW: http://www.cdsec.com/