This service will be undergoing maintenance at 00:00 UTC, 2016-08-01. It is expected to last about 1 hours
Bug 136255 - USB devices hang programs if pulled out on an open()
USB devices hang programs if pulled out on an open()
Status: CLOSED UPSTREAM
Product: Fedora
Classification: Fedora
Component: kernel (Show other bugs)
rawhide
All Linux
medium Severity high
: ---
: ---
Assigned To: Pete Zaitcev
:
: 138259 140964 143785 152308 (view as bug list)
Depends On:
Blocks: FCMETA_USB
  Show dependency treegraph
 
Reported: 2004-10-18 18:01 EDT by John (J5) Palmieri
Modified: 2013-03-13 00:46 EDT (History)
15 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-02-15 13:03:10 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
Test program (312 bytes, text/plain)
2004-10-18 18:03 EDT, John (J5) Palmieri
no flags Details
Kernel backtrace (1.09 KB, text/plain)
2004-10-19 11:37 EDT, John (J5) Palmieri
no flags Details
Oops in SCSI subsystem (3.83 KB, text/plain)
2004-12-05 16:38 EST, Didier
no flags Details
USB detach/reattach syslog (6.44 KB, text/plain)
2004-12-19 08:13 EST, Didier
no flags Details


External Trackers
Tracker ID Priority Status Summary Last Updated
Linux Kernel 3595 None None None Never

  None (edit)
Description John (J5) Palmieri 2004-10-18 18:01:35 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3)
Gecko/20041012 Epiphany/1.4.4

Description of problem:
Programs that attempt to open a usb-storage device while it is being
pulled out will hang in the open call even if O_NONBLOCK is set.  This
is serious because HAL polls devices such as cdroms and floppies to
know when media has been inserted.  Pulling out the device when a poll
happens causes HAL to hang and devices are no longer autodetected and
configured.

Version-Release number of selected component (if applicable):
tried on kernel-2.6.8 releases 1.541, 1.610, 1.627

How reproducible:
Always

Steps to Reproduce:
1. Plug in a USB mass storage device
2. Note the device node it attaches to
3. Edit the enclosed test program to open this device node
4. gcc test.c -o test
5. strace -tt ./test
6. Yank the usb device out
    

Actual Results:  Program freezes and you can't kill it.

Expected Results:  program continues working

Additional info:
Comment 1 John (J5) Palmieri 2004-10-18 18:03:15 EDT
Created attachment 105403 [details]
Test program
Comment 2 John (J5) Palmieri 2004-10-19 11:37:10 EDT
Created attachment 105450 [details]
Kernel backtrace

Backtrace of test program after it hangs.
Comment 3 David Zeuthen 2004-11-09 09:47:38 EST
*** Bug 138259 has been marked as a duplicate of this bug. ***
Comment 4 Chris Wilcox 2004-11-10 14:54:07 EST
Have an identical problem using RedHat Fedora Core 2, with a 2.6.9 
kernel.  My program polls for USB device insertion and removal by 
opening /dev/sda, /dev/sdb, etc.  I tried with and without O_NONBLOCK,
and it hangs intermittently (but often) either way on device 
removal.  Is there a better way to detect insertion and removal 
events without polling?
Comment 5 Rob Kirkbride 2004-11-22 09:36:45 EST
I actually think the problem is worse than this. If the device is
unmounted rather than being ejected it produces a hang in the hal
daemon (presumably the same hang as above). This was a suggestion by
Kay Siever on the hot plug mailling list and appears to work. ie. This
isn't just about pulling the key out out.
The problem is if you forget to do the eject rather than the unmount,
your USB bus effectively locks up requiring a reboot.
Comment 6 Mikko Huhtala 2004-11-22 11:55:51 EST
> I actually think the problem is worse than this. [...]

Yes, that is also what I reported in my original bug. That bug
(138259) got resolved as a duplicate of this one.

Mikko
Comment 7 Mark Levitt 2004-11-23 11:04:12 EST
I have seen the same thing. 
1)Plug in a USB key drive. Drive is mounted and shows up on desktop.
2)Right click and click Unmount volume. Driver icon goes away.
3) Remove drive.
4) Plug drive in again. Drive is mounted and shows up on desktop.
5) Right click and click Unmount volume. Error message that the device
is busy.
6) Remove device. Icon goes away. 
7) Plug drive in a third time, nothing happens.
Comment 8 Mark Levitt 2004-11-23 11:05:47 EST
Sorry, I should have mentioned that this is on Fedora Core 3 kernel v.
 2.6.9-1.681_FC3 
Comment 9 John (J5) Palmieri 2004-11-23 11:46:27 EST
Mark Levitt, I think that is a different bug alltogether.  It looks
more like bug #132572.  Certant USB devices break the massstorage drivers.
Comment 10 John (J5) Palmieri 2004-11-30 11:20:12 EST
*** Bug 140964 has been marked as a duplicate of this bug. ***
Comment 11 David Zeuthen 2004-12-02 10:33:21 EST
*** Bug 138906 has been marked as a duplicate of this bug. ***
Comment 12 Didier 2004-12-02 11:49:46 EST
Any relation to bug #140356 (SCSI subsystem lockup when removing
IEEE1394 devices) ?
Comment 13 Rob Kirkbride 2004-12-03 07:45:44 EST
I have tried Kernel 2.6.9-RC2 and it works fine with FC3. It mounts
devices etc. as it should and the hal daemon appears to does its job
correctly. I've been running it for a few so far and it's been fine.

Hopefully an offical kernel update can be issued with at least the USB
corrections from RC2 in.
Comment 14 Steve Bergman 2004-12-04 12:23:02 EST
My kernel is 2.6.9-1.681_FC3 and the problem persists.  I just
rebooted and unplugged, plugged my 64MB CF card into my Dazzle* 8-in-1
High Speed USB 2.0 reader and it recognized it when I first started
gnome, and it found it again when I unplugged, plugged, but then when
I tried it again it fails to recognize it.  Logging out and logging
back in does not help.  Nor does restarting haldaemon.  Only a reboot
gets it "working" again.  Though only for a very short time until it
fails again.
Comment 15 John (J5) Palmieri 2004-12-05 05:59:37 EST
Card readers are polled by HAL to detect media insertion.  This
involves an open() so if you pull the card out while the reader is
being polled the system call hangs.
Comment 16 Didier 2004-12-05 16:38:19 EST
Created attachment 107913 [details]
Oops in SCSI subsystem

As a follow-up to my own comment #12, "cat /proc/scsi/sci" hangs too after some
detach/attach cycles, same behaviour as bug #140356 (where SCSI hangs after one
detach, reproducable).

Contrary to bug #140356, I do get an oops here (see attachment).
Comment 17 Didier 2004-12-19 08:08:21 EST
Problem persists with 2.6.9-1.715_FC3 : detaching and reattaching a
digicam (Pentax Optio 750Z) to the USB port hangs the SCSI subsystem,
requiring a reboot to restore USB and/or Firewire operations (my FC2
uptimes of 20+ days are decimated).

root        29  0.0  0.0     0    0 ?        D    12:49   0:00 [khubd]
root      3940  0.0  0.9  8916 7196 ?        Ds   12:51   0:02 hald
didier    7822  0.2  1.6 24556 12516 ?       D    13:31   0:04
/usr/bin/gtkam
didier    8031  0.2  3.9 125004 30600 ?      Dl   13:32   0:03 gthumb
root      8658  0.0  0.0     0    0 ?        D    13:37   0:00 [scsi_eh_1]
root      8659  0.0  0.0     0    0 ?        S    13:37   0:00
[usb-storage]
root      8993  0.0  0.0  3812  636 pts/6    D+   13:38   0:00 fdisk -l
Comment 18 Didier 2004-12-19 08:13:01 EST
Created attachment 108855 [details]
USB detach/reattach syslog

After syncing and detaching, udev removes SCSI node, and kernel reports scsi &
FAT I/O errors.
After reattaching, udev recreates sda node, but hal times out.
Comment 19 David Zeuthen 2005-01-03 14:07:12 EST
*** Bug 143785 has been marked as a duplicate of this bug. ***
Comment 20 David Zeuthen 2005-03-28 13:40:25 EST
*** Bug 152308 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.