Opened 2 days ago

Last modified 46 minutes ago

#19105 new bug

FAT: KDLs on device removal without unmount

Reported by: Catmengi Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: File Systems/FAT Version: R1/beta5
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description (last modified by Catmengi)

After disconnecting pen drive it leaves phantom /dev/disk/usb/* node. Partition isn't unmounting which leads to "general protection exception" 0x0 Tested on: x64 laptop (i3 6006u "acer travelmate p259")

Steps to recreate: connect pendrive, let haiku mount partition, disconnect pendrive, /dev/disk/usb/* will stay. If you didn't open mounted partition before and try to open it you will have kernel panic(at least in gui)

FAT driver possible not catch some kind of "detach" event for unmounting. Or it dont have proper checks for existence of the mounted device. beFs handle this properly and unmounts when usb is detached

Attachments (2)

IMG_20240917_142227.jpg (4.6 MB ) - added by Catmengi 2 days ago.
Panic log
17265755240137742572183679333737.jpg (1.8 MB ) - added by Catmengi 2 days ago.

Change History (29)

by Catmengi, 2 days ago

Attachment: IMG_20240917_142227.jpg added

Panic log

comment:1 by Catmengi, 2 days ago

Description: modified (diff)

comment:2 by Catmengi, 2 days ago

Description: modified (diff)

comment:3 by waddlesplash, 2 days ago

Component: DriversFile Systems/FAT
Priority: highnormal

If you didn't Unmount/"Eject" before disconnecting the pendrive, then some misbehavior is expected because there may be writes that weren't flushed to the disk, and you may get data loss. The system shouldn't crash, of course, but disconnecting disks without unmounting them isn't good behavior regardless.

comment:4 by Catmengi, 2 days ago

Note that crash is going even without writing anything to it. It crashes on attempt to read this phantom device

comment:5 by Catmengi, 2 days ago

Also phantom /dev/disk/usb nodes is quite bad for tty users (and maybe system)

comment:6 by waddlesplash, 2 days ago

The "phantom nodes" should go away if you unmount the disk properly before removing it. If you don't mount the device at all after plugging it in, they should also go away when you remove it in that case too.

comment:7 by Catmengi, 2 days ago

Attempt to open right click button leads to gui freeze, then kernel panic. I'll add an attachment

by Catmengi, 2 days ago

comment:8 by waddlesplash, 2 days ago

This is with the disk still inserted?

comment:9 by Catmengi, 2 days ago

Without. With inserted is everything ok, BUT /dev/disk/usb/* still exist

comment:10 by Catmengi, 2 days ago

NEW INFO: device nodes is deleting but /dev/disk/usb/* is not deleted

comment:11 by Catmengi, 2 days ago

Additional info: partition disappeared now, in 5 seconds ± but /dev path still exists, kernel's device nodes in this path is deleted

comment:12 by waddlesplash, 2 days ago

I would expect the /dev file to disappear only after both unmount and then removal of the device, I think.

comment:13 by Catmengi, 2 days ago

Files in /dev/disk/usb/*/* path is deleting after hot unplug drive. This is ok) path/directory isn't deleting itself

comment:14 by Catmengi, 2 days ago

This somehow leading that every pen-drive reconnection create new /dev/disk/usb entry. Leading to garbage in /dev after time

comment:15 by Catmengi, 44 hours ago

Please, can you change ticket to kernel/other suitable? This bug isnt related to FAT FS, its related to /dev

comment:16 by waddlesplash, 44 hours ago

Summary: /dev/disk/usb phantom nodes after disconnecting pen driveFAT: KDLs on device removal without unmount

All the images you have posted are kernel panics in the FAT driver, so it definitely is. Whether or not the node "disappears" is probably related to this.

comment:17 by Catmengi, 43 hours ago

Ok, i agree with this. Currently the issue that this phantom disk crashes kernel. It's not unmounted on hot unplug. /dev/disk/usb/* path isnt deleted leading to useless garbage in it. Possible, the part of kernel that work with pen drive know that it disconnected, but there isnt any automatic unmounting mechanism(or it is) for hot unplug in FAT driver (befs driver possible have this, it isnt crashing os and partition content is not visible after hot unplug). I think this issue can be solved in this way(adding some kind of signaling from device driver, usb drive in this case to fat driver to force unmount partitions that was on this device). But im not an expert in os architecture and haiku's codebase, so this may not be an ideal solution.

comment:18 by Catmengi, 43 hours ago

Even attempt to open right click menu of this fat partition crashing the whole system. This isnt the case with BeFS, so this possible really fat issue. Befs unmount property automatically.

comment:19 by waddlesplash, 43 hours ago

If you are pulling the device without unmounting it in the right-click menu, you are definitely going to lose data whether you're on BFS or FAT.

comment:20 by Catmengi, 37 hours ago

Doesn't matter system shouldn't crash

comment:21 by waddlesplash, 36 hours ago

Sure, which is why this ticket exists. But I'm just noting that even once the kernel crashes are fixed, pulling devices isn't good behavior anyway and will certainly get you in trouble.

comment:22 by Catmengi, 36 hours ago

Description: modified (diff)

comment:23 by Catmengi, 35 hours ago

Description: modified (diff)

comment:24 by Catmengi, 2 hours ago

Is anything about this issue changed yet?

comment:25 by Catmengi, 2 hours ago

Is it ok if you (waddlesplash) change this bug priority to high? Or it isnt too much critical?

comment:26 by Catmengi, 2 hours ago

Also may this be an issue of the new fat driver only? As i read from the beta 5 change log, it use new fat driver from freebsd which may have another method of handling disconnect of the device. I need to do some test on haiku hrev1 beta 4

comment:27 by waddlesplash, 46 minutes ago

Please be patient and don't comment every day. Haiku is a project mostly run by volunteers, things take time.

Note: See TracTickets for help on using tickets.