Bug 5332

Summary: CPU Overloaded after USB Stick Unmount using File Manager
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Razvan Ionescu <razvanx.ionescu>
Component: coreAssignee: Marius Avram <marius.avram>
Status: RESOLVED WORKSFORME QA Contact: Lucian Musat <georgex.l.musat>
Severity: normal    
Priority: Medium CC: alexandru.c.georgescu, corneliux.stoicescu, cristian.iorga, laurentiu.palcu, meta.mr.watcher, meta.watcher, tom.zanussi
Version: 1.5   
Target Milestone: 1.7 M3   
Hardware: Other   
OS: x86   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Razvan Ionescu 2013-10-10 08:00:18 UTC
Generic x86 - AtomPC

TEST - CPU overload
1. Open terminal and issue top -> Nothing unusual
2. Insert USB stick and open FileManager. Create a folder on the stick. (optional)
3. Open terminal and issue top -> Nothing unusual
4. Unmount the USB stick.
5. Open terminal and issue top -> pcmanfm (File Manager) - 50% CPU !!!
Even if you close the File Manager, the pcmanfm PID will remain hanged up.

top snapshot after stick was unmounted and file manager closed:

  PID  PPID USER     STAT   VSZ %VSZ %CPU COMMAND
  704     1 root     R    67412   7%  50% pcmanfm
  698   546 root     S     4932   0%   0% sshd: root@pts/1
  701   700 root     R     2644   0%   0% top
  693     1 root     S    27996   3%   0% matchbox-terminal
Comment 1 Razvan Ionescu 2013-10-10 09:10:00 UTC
Tested with:
poky 102bf5e0f640fe85068452a42b85077f1c81e0c9
meta-intel a1138af21f6ba85e79d1422a3f0a3e0c4f658a90
Comment 2 Razvan Ionescu 2013-10-10 10:29:09 UTC
Tested with Generic x86_64 on Sugarbay the percentage is around 12-13%.

  PID  PPID USER     STAT   VSZ %VSZ %CPU COMMAND
 1545     1 root     R     484m  13%  13% pcmanfm
  769     1 root     S     187m   5%   0% matchbox-terminal
  760   703 root     S     132m   3%   0% matchbox-panel --titlebar --start-applets showdesktop,windowselector --end-applets cloc
  634   617 root     S <   120m   3%   0% /usr/bin/Xorg :0 -br -pn
 

When the user unmounts the sdb, the file manager windows is closing (both on genericx86 and x86_64). Each time the process remains hanged and consumes CPU.
Comment 3 Razvan Ionescu 2013-10-10 11:08:05 UTC
Testing the bug on Sugarbay, using a Sugarbay image (not generic), the bug reproduces with 12-13% CPU Usage after unmount. Same problem with the hanging PID.

  PID  PPID USER     STAT   VSZ %VSZ %CPU COMMAND
  836     1 root     R     420m  11%  13% pcmanfm
  788     1 root     S     187m   5%   0% matchbox-terminal
  776   721 root     S     132m   3%   0% matchbox-panel --titlebar --start-applets showdesktop,windowselector --end-applets cloc
Comment 4 Stoicescu Cornel 2013-10-11 14:31:04 UTC
NOTE: Does not happen with generic86-64 image on Sugarbay platform.
Comment 5 Stoicescu Cornel 2013-10-11 14:50:47 UTC
NOTE: Actually, it does. See below for more information:

If the user unmounts using the file manager's "Unmount Volume" option (right click on the sdb drive) the issue will appear.

If the user unmounts the volume using the 'umount /dev/sdb' command, the issue will not happen. 

This seems like an issue with the file manager.
Comment 6 Alexandru Georgescu 2013-10-23 08:15:41 UTC
Happens with n450 images as well on a AtomPC(Lenovo S10-3 HW).
Comment 7 Darren Hart 2013-12-20 23:55:08 UTC
Yes, an issue with the file manager. Saul?
Comment 8 Marius Avram 2014-01-23 13:53:32 UTC
I believe this is more of a libfm problem.
It looks like the function on_mount_action_finished from libfm/src/gtk  is never called and the thread on which the USB stick was running is looping to infinity. The on_mount_action_finished is passed as a callback to g_mount_unmount_with_operation, but for some reason the callback is never called. 

I also noticed that there is warning when unmounting and USB stick:

(pcmanfm:960): GLib-CRITICAL **: g_source_attach: assertion 'source->context == NULL' failed. 

There must be a synchronization problem somewhere because the file managers work well when is ran using: pcmanfm --sync (Does X calls synchronous).
Comment 9 Marius Avram 2014-01-29 15:18:13 UTC
In the libfm source code there is a FIXME comment:
file libfm/src/gtk/fm-places-view.c, function on_unmount().

The libfm library creates a mount(FM_PLACES_ITEM_MOUNT) in my test case (genericx86). It could be possible that a volume(FM_PLACES_ITEM_VOLUME) won't break pcmanfm in the same way. But i wasn't able to discover the differences between the two (a mount vs a volume) or the place where they are assigned.

A fix could be to try to force the mounting as a VOLUME and not as a simple MOUNT.
Comment 10 Marius Avram 2014-08-19 11:15:38 UTC
I've took another look into this and it seems that when you insert an USB stick the File Manager doesn't show it into the Places sidebar like it usually did. However the stick is successfully mounted and information about it can be viewed by typing the "mount" command and its content can be accessed by navigating to its mounted path.

This implies the bug doesn't happen anymore, but not for the right reasons. Possibly the fact that the File Manager doesn't receive the mounting and unmounting events/signals prevents the bug from showing up.
Comment 11 Lucian Musat 2014-08-19 11:31:08 UTC
Hy Marius,

There is a bug opened for that:
https://bugzilla.yoctoproject.org/show_bug.cgi?id=6492
Comment 12 Marius Avram 2014-09-12 12:52:41 UTC
From what I tested this bug doesn't happen any more.