Received: from fort-point-station.mit.edu (FORT-POINT-STATION.MIT.EDU [18.7.7.76]) by krbdev.mit.edu (8.9.3) with ESMTP id SAA24858; Tue, 15 Jul 2003 18:36:29 -0400 (EDT) Received: from central-city-carrier-station.mit.edu (CENTRAL-CITY-CARRIER-STATION.MIT.EDU [18.7.7.72]) by fort-point-station.mit.edu (8.12.4/8.9.2) with ESMTP id h6FMa96W024287; Tue, 15 Jul 2003 18:36:10 -0400 (EDT) Received: from manawatu-mail-centre.mit.edu (MANAWATU-MAIL-CENTRE.MIT.EDU [18.7.7.71]) by central-city-carrier-station.mit.edu (8.12.4/8.9.2) with ESMTP id h6FMWjPa020997; Tue, 15 Jul 2003 18:32:45 -0400 (EDT) Received: from cathedral-seven.mit.edu (CATHEDRAL-SEVEN.MIT.EDU [18.7.16.65]) ) by manawatu-mail-centre.mit.edu (8.12.4/8.12.4) with ESMTP id h6FMWiFJ016685; Tue, 15 Jul 2003 18:32:44 -0400 (EDT) Received: (from epeisach@localhost) by cathedral-seven.mit.edu (8.9.3p2) id SAA17379; Tue, 15 Jul 2003 18:32:44 -0400 (EDT) Date: Tue, 15 Jul 2003 18:32:44 -0400 (EDT) Message-Id: <200307152232.SAA17379@cathedral-seven.mit.edu> From: Ezra Peisach To: rt-comment@krbdev.mit.edu Subject: Re: [krbdev.mit.edu #1665] memory leak in krb5_{init,free}_context In-Reply-To: Cc: krb5-prs@MIT.EDU RT-Send-Cc: X-RT-Original-Encoding: iso-8859-1 Content-Length: 1026 Our code base has not changed in a while. I noticed this once... krb5_init_context does initialize the error tables. krb5_init_ets does an initiazlie_XXX_error_table() each time. This calls add_error_table - this adds the error table to the list. Note - this is with our com_err code. Note2: nothing has changed in this code since 2001. Note3: Probably when we modified init_context to initialize the error tables (which is a good think - the error was introduced) Now - usually - all our code calls init_context once or twice (i.e. the internal gssapi krb5_context, the krb4 one, etc) - so no-one is hurt. In the example code - memory will leak. While in theory - we could add a reference count for each error table, krb5_free_ets does nothing... A simple code change would be to lib/krb5/error_tables/init_ets to have a simple reference count which is incremented when someone calls it - and a decrement in free_ets would make sense - then have free_ets release the error table if the count reaches zero. Ezra