*BSD News Article 17406


Return to BSD News archive

Newsgroups: comp.os.386bsd.bugs
Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!elroy.jpl.nasa.gov!swrinde!gatech!howland.reston.ans.net!noc.near.net!uunet!psinntp!fstalb!mooreb
From: mooreb@fac.com (Brian Moore)
Subject: ioctls and core dumps
Organization: First Albany Corp.
Date: Tue, 22 Jun 1993 17:37:15 GMT
Message-ID: <1993Jun22.173715.6498@fac.com>
Lines: 31

I've had a rather wierd problem with ioctls...  Here's the situation.
I'm working on a device driver for the Mitsumi cd-rom drive.  One of
the ioctls I was working on was DIOCGDINFO, which is supposed to
return a disklabel.  My driver doesn't return anything for that ioctl
yet.  It doesn't even reference the data pointer at all.  I wrote up
a test program to try some of the ioctls I was working on.  When I
tried the DIOCGDINFO, passing in 0 for the data, the program dumped
core in the exit processing.  Thereafter, the program would dump core
at the very beginning of the program no matter what ioctl I tried.
Even if I rebooted, the program would dump core right at the start.
A copy of the program made after it core dumped the first time would
also core dump.  But a copy made before the first core dump would work
fine.  The working and non-working copies compared as equal, so the
binary wasn't being changed in the filesystem.  I fixed the dumps by
passing in a struct disklabel in the DIOCGDINFO ioctl.  This makes it
look like the ioctl processing in the c library or kernel are doing
more than passing the data pointer on.  I certainly expect the kernel
to do some checking, but I don't see why the program should continue
to dump core.

The $42 question is...  Why did the program continue to dump core?
The only thing I could think of is that perhaps the ioctl processing
in the c library or the kernel mucks with the data area (mprotect,
clears it, or something else), which would really be the start of the
program because of the 0.  As such, it might cause problems for future
runs of that program if it is kept in swap or cache or whatever.  But
why would the program continue to core dump across reboots?
-- 
Brian Moore, mooreb@fac.com  | I wrote up a nice script to truncate all News&
First Albany Corp. Sysadmin  | Mail sigs that are greater than 4 lines long.
standard disclaimers apply   | It is still in beta testing due to an off-by-