NetBSD Problem Report #35131
From dholland@eecs.harvard.edu Sun Nov 26 19:29:42 2006
Return-Path: <dholland@eecs.harvard.edu>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by narn.NetBSD.org (Postfix) with ESMTP id 6C7C363B400
for <gnats-bugs@gnats.NetBSD.org>; Sun, 26 Nov 2006 19:29:42 +0000 (UTC)
Message-Id: <20061126192823.12726F8C2@tanaqui.eecs.harvard.edu>
Date: Sun, 26 Nov 2006 14:28:22 -0500 (EST)
From: dholland@eecs.harvard.edu
Reply-To: dholland@eecs.harvard.edu
To: gnats-bugs@NetBSD.org
Subject: memory leak in talkd
X-Send-Pr-Version: 3.95
>Number: 35131
>Category: bin
>Synopsis: talkd leaks the list of utmp entries
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Nov 26 19:30:01 +0000 2006
>Closed-Date: Sun Jul 13 20:13:20 +0000 2008
>Last-Modified: Sun Jul 13 20:13:20 +0000 2008
>Originator: David A. Holland <dholland@eecs.harvard.edu>
>Release: NetBSD 4.99.3 (-20061010, also in -20061125)
>Organization:
Harvard EECS
>Environment:
System: NetBSD tanaqui 4.99.3 NetBSD 4.99.3 (TANAQUI) #6: Tue Oct 10 19:32:37 EDT 2006 dholland@tanaqui:/usr/src/sys/arch/i386/compile/TANAQUI i386
Architecture: i386
Machine: i386
>Description:
talkd uses usr.bin/who's utmp reading code (utmpentry.c), which
maintains a list of info from utmp/utmpx entries.
When the data is reloaded (if utmp or utmpx has been changed), the
code drops the old list on the floor. There's a freeutentries(), with
external linkage, but it's never called, either internally or from
talkd.
This is not a big deal because talkd is not a long-running process.
(It could be on a large shellserver with many users, if there were a
lot of talk traffic, but such machines are rare and talk is no longer
widely used.)
>How-To-Repeat:
-
>Fix:
Call freeutentries when reloading.
If the caller of getutentries is supposed to call freeutentries on the
results, as appears to be the case, do so in talkd, and add the
necessary refcounting internally.
If not, check other callers to make sure they don't retain pointers to
the information past another call to getutentries, and make
freeutentries file-static to avoid accidents.
Or whatever...
(It also might be a good idea to document the intended model in
utmpentry.h.)
>Release-Note:
>Audit-Trail:
From: "David A. Holland" <dholland@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/35131 CVS commit: src
Date: Sun, 13 Jul 2008 20:07:49 +0000 (UTC)
Module Name: src
Committed By: dholland
Date: Sun Jul 13 20:07:49 UTC 2008
Modified Files:
src/games/dm: dm.c
src/libexec/comsat: comsat.c
src/usr.bin/systat: vmstat.c
src/usr.bin/users: users.c
src/usr.bin/who: utmpentry.c utmpentry.h
src/usr.sbin/rwhod: rwhod.c
src/usr.sbin/syslogd: syslogd.c
Log Message:
Clarify how one is supposed to use the pointers returned by getutentries()
(the utmpentry.c code), specifically with respect to who owns them and
when to free them. Now they're owned by utmpentry.c, only. Abolish the
freeutentries() function, which was the wrong abstraction; add instead
endutentries(), which flushes out the internally managed memory.
Update callers as necessary. Some (e.g. talkd) had been leaking memory;
others (e.g. syslogd) had been accidentally freeing and reloading utmp
more often than necessary. There are a couple untidy bits in users and
rwhod that someone should look after sometime, maybe.
Fixes PR bin/35131, which was about talkd's memory leak.
To generate a diff of this commit:
cvs rdiff -r1.24 -r1.25 src/games/dm/dm.c
cvs rdiff -r1.36 -r1.37 src/libexec/comsat/comsat.c
cvs rdiff -r1.70 -r1.71 src/usr.bin/systat/vmstat.c
cvs rdiff -r1.13 -r1.14 src/usr.bin/users/users.c
cvs rdiff -r1.14 -r1.15 src/usr.bin/who/utmpentry.c
cvs rdiff -r1.6 -r1.7 src/usr.bin/who/utmpentry.h
cvs rdiff -r1.35 -r1.36 src/usr.sbin/rwhod/rwhod.c
cvs rdiff -r1.84 -r1.85 src/usr.sbin/syslogd/syslogd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 13 Jul 2008 20:13:20 +0000
State-Changed-Why:
fixed.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.