Skip Menu |
 

To: krb5-bugs@mit.edu
Subject: [Will Fiveash] Fwd: Fwd: possible memory leak in 1.3.2
From: Ken Raeburn <raeburn@MIT.EDU>
Date: Thu, 11 Mar 2004 03:48:51 -0500

I think Will's right about this KDC memory leak in TCP configurations.
Probably kill_tcp_connection should free the storage when a TCP
connection goes away. Need to look closer.
Download (untitled)
message/rfc822 5.5KiB
Return-Path: <william.fiveash@sun.com>
Received: from po9.mit.edu (po9.mit.edu [18.7.21.65])
by po9.mit.edu (Cyrus v2.1.5) with LMTP; Wed, 10 Mar 2004 20:02:22 -0500
X-Sieve: CMU Sieve 2.2
Received: from pacific-carrier-annex.mit.edu by po9.mit.edu (8.12.4/4.7) id i2B12LKc026252; Wed, 10 Mar 2004 20:02:21 -0500 (EST)
Received: from brmea-mail-3.sun.com (brmea-mail-3.Sun.COM [192.18.98.34])
by pacific-carrier-annex.mit.edu (8.12.4/8.9.2) with ESMTP id i2B12K1U001912
for <raeburn@mit.edu>; Wed, 10 Mar 2004 20:02:20 -0500 (EST)
Received: from centralmail2brm.Central.Sun.COM ([129.147.62.14])
by brmea-mail-3.sun.com (8.12.10/8.12.9) with ESMTP id i2B12Jex028676
for <raeburn@mit.edu>; Wed, 10 Mar 2004 18:02:19 -0700 (MST)
Received: from alton.central.sun.com (alton.Central.Sun.COM [129.153.128.101])
by centralmail2brm.Central.Sun.COM (8.12.10+Sun/8.12.10/ENSMAIL,v2.2) with ESMTP id i2B12Jbq002535
for <raeburn@mit.edu>; Wed, 10 Mar 2004 18:02:19 -0700 (MST)
Received: from alton.central.sun.com (localhost [127.0.0.1])
by alton.central.sun.com (8.12.10+Sun/8.12.10) with ESMTP id i2B12IpU881138
for <raeburn@mit.edu>; Wed, 10 Mar 2004 19:02:18 -0600 (CST)
Received: (from willf@localhost)
by alton.central.sun.com (8.12.10+Sun/8.12.10/Submit) id i2B12IkC881137
for raeburn@mit.edu; Wed, 10 Mar 2004 19:02:18 -0600 (CST)
X-Authentication-Warning: alton.central.sun.com: willf set sender to william.fiveash@sun.com using -f
Date: Wed, 10 Mar 2004 19:02:18 -0600
From: Will Fiveash <william.fiveash@sun.com>
To: Ken Raeburn <raeburn@mit.edu>
Subject: Fwd: Fwd: possible memory leak in 1.3.2
X-Gnus-Mail-Source: pop:raeburn@nil
Message-ID: <20040311010218.GC159530@sun.com>
Mime-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
protocol="application/pgp-signature"; boundary="lteA1dqeVaWQ9QQl"
Content-Disposition: inline
User-Agent: Mutt/1.4.2i
X-Spam-Score: -4.9
X-Spam-Flag: NO
X-Scanned-By: MIMEDefang 2.28 (www . roaringpenguin . com / mimedefang)
Lines: 131
Xref: all-in-one personal:17575 all.2004-03:896


--lteA1dqeVaWQ9QQl
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Ken,

I've sent this message a couple times to krbdev@MIT.EDU and last time
also to Jeffrey Altman. I don't know why I haven't heard anything so I
thought I'd see if you can get this e-mail.

----- Forwarded message from Will Fiveash <william.fiveash@sun.com> -----

Date: Tue, 9 Mar 2004 10:01:44 -0600
From: Will Fiveash <william.fiveash@sun.com>
Subject: Fwd: possible memory leak in 1.3.2
To: MIT Kerberos Dev List <krbdev@MIT.EDU>
Cc: Jeffrey Altman <jaltman@columbia.edu>
Mail-Followup-To: MIT Kerberos Dev List <krbdev@MIT.EDU>,
Jeffrey Altman <jaltman@columbia.edu>

I sent this yesterday but I never saw it on the krbdev list. BTW, I've
confirmed that there is a memory leak. I've attached a patch.

----- Forwarded message from Will Fiveash <william.fiveash@sun.com> -----

Date: Mon, 8 Mar 2004 18:33:26 -0600
From: Will Fiveash <william.fiveash@sun.com>
Subject: possible memory leak in 1.3.2
To: MIT Kerberos Dev List <krbdev@MIT.EDU>
Mail-Followup-To: MIT Kerberos Dev List <krbdev@MIT.EDU>

I'm testing the kdc with "kdc_ports =3D 0" in the kdc.conf which forces the=
kdc
to use TCP. What I notice is the virt. memory size of the kdc continues to
grow as I run 40 instances of kinit's over and over. I suspect a memory le=
ak
but I'm not sure at this point so I thought I'd see if someone on the list =
can
confirm my suspicion regarding certain fuctions. In src/kdc/network.c I se=
e:

add_fd (struct socksetup *data, int sock, int conntype,
void (*service)(struct connection *, const char *, int))
{
struct connection *newconn;
void *tmp;

newconn =3D malloc(sizeof(*newconn));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
if (newconn =3D=3D 0) {
data->retval =3D errno;
com_err(data->prog, errno,
"cannot allocate storage for connection info");
return 0;
}
if (!ADD(connections, newconn, tmp)) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
data->retval =3D errno;
com_err(data->prog, data->retval, "cannot save socket info");
free(newconn);
return 0;
}

and later there is:

static void
kill_tcp_connection(struct connection *conn)
{
delete_fd(conn);
^^^^^^^^^^^^^^^ does not free(conn)
if (conn->u.tcp.response)
krb5_free_data(kdc_context, conn->u.tcp.response);
if (conn->u.tcp.buffer)
free(conn->u.tcp.buffer);
FD_CLR(conn->fd, &sstate.rfds);
FD_CLR(conn->fd, &sstate.wfds);
if (sstate.max =3D=3D conn->fd + 1)
while (sstate.max > 0
&& ! FD_ISSET(sstate.max-1, &sstate.rfds)
&& ! FD_ISSET(sstate.max-1, &sstate.wfds)
/* && ! FD_ISSET(sstate.max-1, &sstate.xfds) */
)
sstate.max--;
close(conn->fd);
conn->fd =3D -1;
tcp_data_counter--;
}

So how is the newconn malloc'ed in add_fd() free()'ed?

--=20
Will Fiveash
Sun Microsystems Inc.
Austin, TX, USA (TZ=3DCST6CDT)
GPG PubKey ID:0x7D31DC39, Key server: www.keyserver.net



Show quoted text
----- End forwarded message -----

--=20
Will Fiveash
Sun Microsystems Inc.
Austin, TX, USA (TZ=3DCST6CDT)
GPG PubKey ID:0x7D31DC39, Key server: www.keyserver.net



----- End forwarded message -----

--=20
Will Fiveash
Sun Microsystems Inc.
Austin, TX, USA (TZ=3DCST6CDT)
GPG PubKey ID:0x7D31DC39, Key server: www.keyserver.net

--lteA1dqeVaWQ9QQl
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (SunOS)

iD8DBQFAT7qZ8uNabn0x3DkRAtpJAJ4ldbe1LDtJf4Slm9Aiqra/86otPgCgiiay
7aEdghs+vW4OuiiQZUvxAU8=
=AnxX
-----END PGP SIGNATURE-----

--lteA1dqeVaWQ9QQl--
Date: Thu, 11 Mar 2004 11:17:26 -0500
Subject: Re: [krbdev.mit.edu #2384] [Will Fiveash] Fwd: Fwd: possible memory leak in 1.3.2
From: Ken Raeburn <raeburn@MIT.EDU>
To: rt@krbdev.mit.edu
RT-Send-Cc:
... and it would help people on the mailing list if RT would mention in
the messages it sends out that the message it received had an
attachment (in this case, email from Will) which was not being
forwarded....

Ken
From: raeburn@mit.edu
Subject: CVS Commit
* network.c (delete_fd): Free pointed-to data after removing it from the
connection set.
(kill_tcp_connection): Move delete_fd call to the end.
(accept_tcp_connection): Decrement connection counter again if we drop the
incoming connection for lack of buffer space.


To generate a diff of this commit:



cvs diff -r5.278 -r5.279 krb5/src/kdc/ChangeLog
cvs diff -r5.57 -r5.58 krb5/src/kdc/network.c
From: tlyu@mit.edu
Subject: CVS Commit
pullup from trunk


To generate a diff of this commit:



cvs diff -r5.251.2.17 -r5.251.2.18 krb5/src/kdc/ChangeLog
cvs diff -r5.56 -r5.56.2.1 krb5/src/kdc/network.c
Date: Mon, 22 Mar 2004 18:19:49 -0600
From: Will Fiveash <william.fiveash@sun.com>
To: Ken Raeburn via RT <rt-comment@krbdev.mit.edu>
Subject: Re: [krbdev.mit.edu #2384] CVS Commit
RT-Send-Cc:
On Mon, Mar 22, 2004 at 05:00:07PM -0500, Ken Raeburn via RT wrote:
Show quoted text
> * network.c (delete_fd): Free pointed-to data after removing it from the
> connection set.
> (kill_tcp_connection): Move delete_fd call to the end.
> (accept_tcp_connection): Decrement connection counter again if we drop the
> incoming connection for lack of buffer space.
>
>
> To generate a diff of this commit:
>
>
>
> cvs diff -r5.278 -r5.279 krb5/src/kdc/ChangeLog
> cvs diff -r5.57 -r5.58 krb5/src/kdc/network.c

Ken, I just tried looking at this diff via the MIT anonymous CVS server
but it doesn't appear to be there. Does it take a while for this change
to appear there or am I doing something wrong? I'm using:

CVSROOT=:pserver:anoncvs@anoncvs.mit.edu:/cvs/krbdev

cvs checkout krb5/src/kdc/network.c
cvs diff -r5.57 -r5.58 krb5/src/kdc/network.c

which returns:
cvs server: tag 5.58 is not in file krb5/src/kdc/network.c
--
Will Fiveash
Sun Microsystems Inc.
Austin, TX, USA (TZ=CST6CDT)
GPG PubKey ID:0x7D31DC39, Key server: www.keyserver.net
Download (untitled)
application/pgp-signature 185B

Message body not shown because it is not plain text.

To: rt@krbdev.mit.edu
Subject: Re: [krbdev.mit.edu #2384] CVS Commit
From: Tom Yu <tlyu@mit.edu>
Date: Mon, 22 Mar 2004 19:23:31 -0500
RT-Send-Cc:
Show quoted text
>>>>> "Will" == william fiveash@sun com via RT <rt-comment@krbdev.mit.edu> writes:

Show quoted text
Will> Ken, I just tried looking at this diff via the MIT anonymous CVS
Will> server but it doesn't appear to be there. Does it take a while
Will> for this change to appear there or am I doing something wrong?

I believe the anoncvs server is only updated from our development
repository nightly.

---Tom