hald hangs when usb card reader/writer plugged in

Bug #14907 reported by Jeremy Lynton
8
Affects Status Importance Assigned to Milestone
hal (Ubuntu)
Invalid
Medium
Martin Pitt

Bug Description

Hoary RC
Verbatim hi-speed usb card reader/writer, model UISDMC2W

If I plug it in with or without compact flash card inserted nothing happens

dmesg output (last lines);
eth0: no IPv6 routers present
cdrom: dropping to single frame dma
program eject is using a deprecated SCSI ioctl, please convert it to SG_IO
usb 5-5: new high speed USB device using ehci_hcd and address 3
Initializing USB Mass Storage driver...
scsi2 : SCSI emulation for USB Mass Storage devices
usbcore: registered new driver usb-storage
USB Mass Storage support registered.
usb-storage: device found at 3
usb-storage: waiting for device to settle before scanning
Vendor: USB2.0 Model: CardReader CF RW Rev: 0.0>
Type: Direct-Access ANSI SCSI revision: 00
SCSI device sdc: 15744 512-byte hdwr sectors (8 MB)
sdc: Write Protect is off
sdc: Mode Sense: 02 00 00 00
sdc: assuming drive cache: write through
SCSI device sdc: 15744 512-byte hdwr sectors (8 MB)
sdc: Write Protect is off
sdc: Mode Sense: 02 00 00 00
sdc: assuming drive cache: write through
/dev/scsi/host2/bus0/target0/lun0: p1
Attached scsi removable disk sdc at scsi2, channel 0, id 0, lun 0
Vendor: USB2.0 Model: CardReader SD RW Rev: 0.0>
Type: Direct-Access ANSI SCSI revision: 00
Attached scsi removable disk sdd at scsi2, channel 0, id 0, lun 1
Vendor: USB2.0 Model: CardReader SM RW Rev: 0.0>
Type: Direct-Access ANSI SCSI revision: 00
Attached scsi removable disk sde at scsi2, channel 0, id 0, lun 2
Vendor: USB2.0 Model: CardReader MS RW Rev: 0.0>
Type: Direct-Access ANSI SCSI revision: 00
Attached scsi removable disk sdf at scsi2, channel 0, id 0, lun 3
usb-storage: device scan complete
jeremy@ubuntu1:~$

if I then try to plug in any other usb storage device they do not automount
(normally they do automount fine), and if I go to System > Preferences >
Removable drives and media, the normal window does not open, after some 30
second I get a small window that says hald service is not running. After a
reboot all is well again (other usb devices automounting correctly).

Revision history for this message
Matt Zimmerman (mdz) wrote :

This typically means that one of the system calls hal makes is hanging. Try:

strace -p <pid>

where <pid> is the process ID for hald, and see where it is hung up.

Revision history for this message
Jeremy Lynton (lynton) wrote :

(In reply to comment #1)
> This typically means that one of the system calls hal makes is hanging. Try:
>
> strace -p <pid>
>
> where <pid> is the process ID for hald, and see where it is hung up.

Should I do this before plugging, or after? And how do I find the <pid>

Revision history for this message
Fabio Massimo Di Nitto (fabbione) wrote :

(In reply to comment #2)
> (In reply to comment #1)
> > This typically means that one of the system calls hal makes is hanging. Try:
> >
> > strace -p <pid>
> >
> > where <pid> is the process ID for hald, and see where it is hung up.
>
> Should I do this before plugging, or after? And how do I find the <pid>

Please try to add ehci_hcd to /etc/hotplug/blacklist and see if the problem still
persists. Apparently the high speed usb driver has some issues and this won't be
the first report :(

Fabio

Revision history for this message
Jeremy Lynton (lynton) wrote :

I have tried that, but the problem persists.

Revision history for this message
Fabio Massimo Di Nitto (fabbione) wrote :

oh i just noticed this lines:

/dev/scsi/host2/bus0/target0/lun0: p1
and
usb-storage: device scan complete

The kernel job stops here and it passes the stuff to userland.
Reassigning to hald that shouldn't crash and it should pass info
to pmount & Co.

Revision history for this message
Jeremy Lynton (lynton) wrote :

So, is there anything more II should do/try, do you need any logs or anything?

Revision history for this message
Jeremy Lynton (lynton) wrote :

I have just done a fresh install of Hoary 5.04 final, and the problem still exists.

Revision history for this message
Martin Pitt (pitti) wrote :

Please do the following without your card reader attached:

 sudo killall hald
 sudo hald --drop-privileges --verbose=yes --daemon=no 2>&1 | tee hal.txt

Wait for the flood of messages to settle, then plug in the reader.

Depending on whether hal actually freezes or crashes you will get back at the
prompt or not. In any case, please attach the resulting hal.txt to this bug
report and tell me what exactly happened (freeze/crash).

Thanks in advance!

Revision history for this message
Jeremy Lynton (lynton) wrote :

Created an attachment (id=2454)
hal.txt as asked for

Martin, I followed your instructions to the letter, and attach the resulting
hal.txt
I waited some time, but was not returned to a prompt, otherwise the computer
continued to work perfectly except that I could not hotplug my USB HD which
normally works fine. After a reboot all is well again (except the card reader).

I am now running a fresh install of kubuntu.

Revision history for this message
Martin Pitt (pitti) wrote :

Hmm, it seems that it really requires a debugging session on your computer, I
can't see anything meaningful in the logs. If you are really adventurous, you
could try to upgrade to Breezy, but Breezy's X.org and some packages are
slightly broken at the moment...

Revision history for this message
Jeremy Lynton (lynton) wrote :

(In reply to comment #10)
Thanks for looking at it. I can't risk breezy as my computer is what I use to
make a living!

BTW, congratulations and thanks to all of you at ubuntu/canonical for all the
great work you do.

Revision history for this message
Martin Pitt (pitti) wrote :

(In reply to comment #9)
> Created an attachment (id=2454) [edit]
> hal.txt as asked for
>
> Martin, I followed your instructions to the letter, and attach the resulting
> hal.txt

Hm, as I already explained, there is nothing meaningful in there... :-(

> I waited some time, but was not returned to a prompt

That means that hald did not crash, but hangs. When it does, can you please do:

  sudo strace /usr/sbin/hald $(pidof hald) 2>&1 | tee hang-trace.txt

wait a bit until nothing happens any more, break with Control-C and attach
hang-trace.txt here?

Revision history for this message
Jeremy Lynton (lynton) wrote :

Created an attachment (id=2560)
hang-trace.txt

here it is, cheers, Jeremy

Revision history for this message
Martin Pitt (pitti) wrote :

(In reply to comment #13)
> Created an attachment (id=2560) [edit]
> hang-trace.txt

Uh, that does not look like it was attached to an already running hal, but
rather was used to start a new hald instance. Can you please execute the command
while hald still runs and has frozen?

  pidof hald

should print a number; if it is empty, then hald is not running.

Revision history for this message
Jeremy Lynton (lynton) wrote :

(In reply to comment #14)

Sorry, I don't understand...
Should I try the previous command - sudo strace /usr/sbin/hald $(pidof hald)
2>&1 | tee hang-trace.txt - BEFORE plugging the card reader, and have it run
while I plug? And this last command - pidof hald - ?

Revision history for this message
Martin Pitt (pitti) wrote :

Sorry for the delay...

(In reply to comment #15)
> Should I try the previous command - sudo strace /usr/sbin/hald $(pidof hald)
> 2>&1 | tee hang-trace.txt - BEFORE plugging the card reader, and have it run
> while I plug?

Right. So, again:

 * detach your card reader
 * reboot your box to make sure you have a clean state
 * sudo strace /usr/sbin/hald $(pidof hald) 2>&1 | tee hang-trace.txt
 * attach your card reader
 * wait a bit until the messages settle down
 * attach hang-trace.txt to this bug report

> And this last command - pidof hald - ?
This is just to check whether hald is actually running, nevermind.

Revision history for this message
Jeremy Lynton (lynton) wrote :

Created an attachment (id=2857)
console output

Hullo,

I tried following your instructions, but they did not produce a hang-trace.txt.

I entered
sudo strace /usr/sbin/hald $(pidof hald) 2>&1 | tee hang-trace.txt
and there was an output (attached as console.txt) but was immediately returned
to the $ prompt.
When I plugged in the card reader there was no more output in the console.

Revision history for this message
Martin Pitt (pitti) wrote :

Argh, I'm such a fool, I mixed up the strace syntax.

 * detach your card reader
 * reboot your box to make sure you have a clean state
 * sudo strace -p $(pidof hald) 2>&1 | tee hang-trace.txt
 * attach your card reader
 * wait a bit until the messages settle down
 * attach hang-trace.txt to this bug report

Then, to get a clean state again, eithe just reboot, or do

 * press Control-C
 * sudo killall hald
 * sudo /etc/init.d/dbus-1 restart

Sorry for the mess, I was confused...

Revision history for this message
Jeremy Lynton (lynton) wrote :

Created an attachment (id=3134)
hang-trace.txt (new)

It worked this time (the trace, not the card reader), thanks

Revision history for this message
Martin Pitt (pitti) wrote :

Thanks for the trace. So after seeing

  open("/dev/hdb", O_RDONLY|O_NONBLOCK|O_EXCL|O_LARGEFILE

nothing happened any more? hal didn't appear to hang at the time you started the
strace, but it hanged much later when trying to access your CD-ROM (I presume).

Did you enable DMA on your CD-ROM by any chance?

In any case, I believe that the Breezy version should be much more robust
against these kind of errors. Can you test the current live CD?

Revision history for this message
Jeremy Lynton (lynton) wrote :

(In reply to comment #20)
Hello,
No, I left it for a couple of minutes, and nothing more happened.
/dev/hdb is a LG DVD writer with DMA enabled, I didn't try to access it.

I'll try and download the current live breezy cd in the next day or two, and let
you know how that goes.
Regards, Jeremy

Revision history for this message
Martin Pitt (pitti) wrote :

(In reply to comment #21)
> (In reply to comment #20)
> Hello,
> No, I left it for a couple of minutes, and nothing more happened.
> /dev/hdb is a LG DVD writer with DMA enabled, I didn't try to access it.

Please try if it works when you disable DMA (I assume you enabled it in
/etc/hdparm.conf). We do not enable DMA on CD drives by default since it leads
to all sorts of spurious b0rkages, just like in your case. Does that help?

> I'll try and download the current live breezy cd in the next day or two, and let
> you know how that goes.

That would also be nice, thanks!

Revision history for this message
Jeremy Lynton (lynton) wrote :

(In reply to comment #22)
I have tried disabling dma, and commented out the relevant modules in /etc/modules
Afer a reboot the card reader worked, but I was without dma!
I am now back to the original config and no card reader (the lesser of two evils).

I haven't yet tried the breezy live cd as I imagine that dma will again not be
enabled by default, and the test would therefore not be very revealing. Is
there any way I can enable dma on breezy live cd?

Revision history for this message
Martin Pitt (pitti) wrote :

(In reply to comment #23)
> (In reply to comment #22)
> I have tried disabling dma, and commented out the relevant modules in /etc/modules
> Afer a reboot the card reader worked, but I was without dma!

The proper way of disabling DMA for CD drives is to not enable it in
/etc/hdparm.conf. It is not enabled by default, so I assume you changed it at
some time (check with "sudo hdparm /dev/cdrom"). There is no need to disable it
entirely, DMA usually works fine for hard drives and the like.

> I haven't yet tried the breezy live cd as I imagine that dma will again not be
> enabled by default, and the test would therefore not be very revealing. Is
> there any way I can enable dma on breezy live cd?

Right, DMA for CD-ROMs is still disabled, exactly for the reason that it seems
to break random things. However, you can always enable it per-device with

 sudo hdparm -d 1 /dev/<device>

Revision history for this message
Martin Pitt (pitti) wrote :

This bug has been marked as a duplicate of bug 36185.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.