From owner-freebsd-hackers Thu Dec 12 7:39:50 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6019537B408 for ; Thu, 12 Dec 2002 07:39:47 -0800 (PST) Received: from storming.org (MG034063.user.veloxzone.com.br [200.165.34.63]) by mx1.FreeBSD.org (Postfix) with SMTP id 5D0B743E4A for ; Thu, 12 Dec 2002 07:39:45 -0800 (PST) (envelope-from cseg@storming.org) Received: (qmail 24720 invoked by uid 1000); 12 Dec 2002 13:32:37 -0300 Date: Thu, 12 Dec 2002 13:32:36 +0300 From: Fred Souza To: hackers@freebsd.org Subject: libkvm breakage? Message-ID: <20021212103236.GA19236@torment.storming.org> Reply-To: cseg@storming.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="17pEHd4RhPHOinZp" Content-Disposition: inline X-Sender: cseg@storming.org Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --17pEHd4RhPHOinZp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello, I've written a small daemon that simply keeps scaning a set of ttys. Whenever it sees that a tty has no processes attached to it, the daemon set the tty's owner:group to whatever was specified. The reason for which I wrote this is that sometimes processes leave orphan ttys (for instance, portupgrade insists on doing it on my system). To gather the list of processes attached to each tty, I use the function kvm_getprocs(3), giving it KERN_PROC_TTY as its "op" argument, so it returns the number of processes using a given tty. My system is currently 5.0-RC, upgraded from a 4.7-STABLE. This daemon, orphanage (http://www.storminng.org/projects/src/orphanage/) used to run just fine. I just tried it on another 4.6-STABLE and it ran fine, but on 5.0-RC it does not. Following is the output of me running the daemon and then gdb with its core. [root@torment][~cseg/Projects/orphanage] make rm -f orphanage cc -O2 -pipe -march=3Dk6-2 -I/usr/local/include -L/usr/local/lib -W -Wall -o orphanage orphanage.c -lkvm [root@torment][~cseg/Projects/orphanage] ./orphanage -dv ttyp* orphanage in free(): error: junk pointer, too high to make sense Abort (core dumped) [root@torment][~cseg/Projects/orphanage] gdb orphanage orphanage.core=20 GNU gdb 5.2.1 (FreeBSD) Copyright 2002 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-undermydesk-freebsd"... (no debugging symbols found)... Core was generated by `orphanage'. Program terminated with signal 6, Aborted. Reading symbols from /usr/lib/libkvm.so.2...(no debugging symbols found)... done. Loaded symbols for /usr/lib/libkvm.so.2 Reading symbols from /usr/lib/libc.so.5...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libc.so.5 Reading symbols from /usr/libexec/ld-elf.so.1...(no debugging symbols found)... done. Loaded symbols for /usr/libexec/ld-elf.so.1 #0 0x280b6f63 in kill () from /usr/lib/libc.so.5 (gdb) where #0 0x280b6f63 in kill () from /usr/lib/libc.so.5 #1 0x2811657a in abort () from /usr/lib/libc.so.5 #2 0x28114ea0 in tcflow () from /usr/lib/libc.so.5 #3 0x28114eec in tcflow () from /usr/lib/libc.so.5 #4 0x28115af1 in free () from /usr/lib/libc.so.5 #5 0x2806e09e in kvm_getprocs () from /usr/lib/libkvm.so.2 #6 0x08049166 in free () #7 0x08048bce in free () --- End Can anyone else reproduce this? Or better yet, does anyone know what's the problem and how to fix it? :-) Thanks, Fred --=20 "A hypothetical paradox: What would happen in a battle between an Enterprise security team, who always get killed soon after appearing, and a squad of Imperial Stormtroopers, who can't hit the broad side of a planet?" -- Tom Galloway --17pEHd4RhPHOinZp Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQE9+GXEKbRS1GgW4fYRArOrAJ9pfdglms4g9z7D+DhkWiCkl1ZRagCcCOwH YysTgdz2sJACBJYJfQENFMA= =LtYX -----END PGP SIGNATURE----- --17pEHd4RhPHOinZp-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message