semi-OT: how to backtrace into the kernel when it's stuck

Danny Milosavljevic danny.milo at gmx.net
Fri Jan 20 11:33:28 PST 2006


Hi,

Am Freitag, den 20.01.2006, 19:36 +0100 schrieb Danny Milosavljevic:
> Hi,
> 
> Am Mittwoch, den 14.12.2005, 10:56 -0500 schrieb David Zeuthen:
> > On Wed, 2005-12-14 at 16:04 +0100, dannym wrote:
> > > Hi,
> > > 
> > > this is kind of off-topic but ...
> > > 
> > > You know, I have this dvd drive...
> > > 
> > > when hald is running and I issue mount on the drive, mount will hang and
> > > not let itself be killed by any means. (the mount will neither succeed
> > > nor fail but will just be "halted")
> > 
> > Yes, both mount and one or more hald-addon-storage processes is in state
> > D (uninteruptible IO), right?
> > 
> > (use ps aux to find the state)
> > 
> > > 
> > > when hald is not running, it works fine.
> > > 
> > > Now I thought it would be nice if I could debug that and for that it
> > > would be nice to see where in the kernel it is waiting around (for some
> > > lock, I suppose) for that mount process.
> > > 
> > > Any ideas how to debug this on the hal side would be nice too :)
> > 
> > Well, a helper of hald is simply polling the drive so we can detect
> > media changes and I believe the driver in the kernel gets very confused
> > and somehow stops servicing IO from user-space processes. 
> 
> Yeah... 
> 
> I've been trying to get a clue how to debug kernel stuff, but so far, no
> luck... (there are tons of howtos on how to debug oopses and whatnot,
> but unfortunately, I don't get an oops...)


> 
> Can you point me to the hal helper source portion so I at least can
> confirm that indeed it is part of the cause (by me creating a small
> standalone prog that does the same things)?


Oooook... 

I tried this prog:
int main()
{ 
  int fd;
  int drive;

  fd = open ("/dev/cdrom1", O_RDONLY | O_NONBLOCK | O_EXCL);

  if (fd < 0 && errno == EBUSY) {
  /* this means the disc is mounted or some other app,
   * like a cd burner, has already opened O_EXCL */
  }

  if (fd < 0) {
    printf("failed\n");
    exit(1);
  }
  while (1) {
    drive = ioctl (fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
    if (drive != CDS_DISC_OK) {
      printf("no\n");
    } else {
      if (ioctl (fd, CDROM_MEDIA_CHANGED, CDSL_CURRENT) &&
      ioctl (fd, CDROM_MEDIA_CHANGED, CDSL_CURRENT)) {
        printf("got media\n");
      }
    }
    printf(".");
    fflush(stdout);
    sleep(2);
  }
}

that outputs:
no
.no
.no
.......................................................................................................................................................................................................................................

But I never get "got media", tried inserting a dvd, re-inserting the
dvd, leaving it in for a bit, removing it for a bit, reinserting again,
nothing worked.

And, which is worse, while the prog above is running:

LC_ALL="C" mount /media/cdrom
mount: block device /dev/hdh is write-protected, mounting read-only
mount: /dev/hdh already mounted or /media/cdrom0 busy

I get that always. I cannot mount it _at all_.
(though it does not hang ...)

cheers,
   Danny

> 
> > 
> > The kernel shouldn't do this, I submit this is a bug with the kernel. To
> > answer your question, no, I don't really know how to fix this, sorry.
> > 
> > Cheers,
> > David
> > 
> > 
> 
> cheers,
>   Danny
> 
> 
> _______________________________________________
> hal mailing list
> hal at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/hal
> 



More information about the hal mailing list