! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Indefinite hang
Status:
RESOLVED: FIXED

Comments

Description flocculant 2017-04-07 10:55:42 CEST
Created attachment 7069 
gdb trace

Thunar hangs not allowing any input to window. Eventually giving 'do you want to close' dialogue. Closes without further issue.

gsb trace attached after attaching to pid.

strace just gives this when attached to running thunar pid 

futex(0x562c4f5889e8, FUTEX_WAIT_PRIVATE, 2, NULL
Comment 1 Alistair Buxton 2017-04-07 11:13:47 CEST
Okay, so from the GDB trace we see that one thread is stuck at:

thunar_file_monitor (monitor=<optimised out>, event_path=0x562c507922a0, other_path=0x562c50b92fa0, event_type=G_FILE_MONITOR_EVENT_MOVED, user_data=<optimised out>) at thunar-file.c:822

This line is:

    G_LOCK (file_rename_mutex);

Which was added to try to fix bug #12264. So this is a mutex deadlock.

My best guess (which I mentioned on the other bug) is that this is something to do with thumbnails. When a file gets moved/renamed, thunar also renames the thumbnail cache file (which I think lives in ~/.cache/thumbnails) to match. This is done inside the mutex, and of course it triggers a further G_FILE_MONITOR_EVENT_MOVED, which has to wait for the mutex to unlock before it can complete.
Comment 2 Alistair Buxton 2017-04-07 11:14:48 CEST
(Copying my comment over from the other bug)

The problem appears to be as follows:

1. A file in that directory gets renamed.
2. G_FILE_MONITOR_EVENT_MOVED happens on thread A.
3. The mutex gets locked.
4. The thumbnail associated with the file gets renamed.
5. G_FILE_MONITOR_EVENT_MOVED happens for the thumbnail on thread B.
6. Thread B waits on the mutex to unlock.
7. Thread A won't unlock the mutex until thread B finished.

This all seems to be a result of:

  thunar_file_move_thumbnail_cache_file (event_path, other_path);

now being inside the mutex. The previous crash was likely caused by a similar chain of events, eg check out this bug report which specifically mentions move_thumbnail:

  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=800723;msg=91
Comment 3 Viktor Odintsev editbugs 2017-04-13 02:19:37 CEST
Created attachment 7074 
Deadlock fix

It seems that mutex may be not released due to return statement in thunar_file_monitor function. This will cause deadlocks.

>          G_LOCK (file_rename_mutex);
>          ...
>          if (other_file == NULL)
>              return;
>          ...
>          G_UNLOCK (file_rename_mutex);

I'm attaching the patch which solves this problem. Thunar no more hangs for me.
Comment 4 flocculant 2017-04-13 08:18:46 CEST
That patch appears to fix the issue for me. Thanks.
Comment 5 Alistair Buxton 2017-04-13 15:44:46 CEST
Well spotted. Patch looks reasonable to me. +1
Comment 6 ToZ editbugs 2017-04-16 22:10:39 CEST
*** Bug 13500 has been marked as a duplicate of this bug. ***
Comment 7 John 2017-04-19 09:33:17 CEST
I built thunar with Viktor's patch and found that after I logged out and logged back in, bug#13472 is fixed by it as well.  I actually think that bug#13481 and bug#13500 are duplicates of my original report, bug#13472 :)

Thanks for the diligence and the patch.
Comment 8 Simon Steinbeiss editbugs 2017-04-28 22:59:46 CEST
Patch pushed to master: https://git.xfce.org/xfce/thunar/commit/?id=4dd549db77838c9345f10a72f10e705f8ae327d4
Comment 9 Git Bot editbugs 2017-07-01 00:34:47 CEST
Viktor Odintsev referenced this bugreport in commit 4dd549db77838c9345f10a72f10e705f8ae327d4

Fix deadlock in mutex causing Thunar to hang (Bug #13481)

https://git.xfce.org/xfce/thunar/commit?id=4dd549db77838c9345f10a72f10e705f8ae327d4
Comment 10 John 2017-07-22 16:28:56 CEST
This bug really grinds my gears.

Thanks to everyone who helped nail it dfown & fix it... but... I'm on F26 now, and it's still using 1.6.11, with this bug.

Can anyone say which version the bugfix will appear in? I hope we're not going to have to wait for this 1.8 milestone, that sounds like it'd be 10 years away.
Comment 11 John 2017-07-22 16:32:26 CEST
Woah! Nevermind. I found the master branch on github and i can see the fix has been included in 1.6.12 which is in rawhide already.

Nice work guise & goilse.

:-)
Comment 12 John 2017-07-22 17:24:55 CEST
Seriously though, I hope someone can push 1.6.12 out of rawhide and into F26.

Thunar is practically unusable with this bug. You're browsing around, you leave Thunar, do some work, basically anything that modifies files Thunar is looking at, and when you go back to Thunar it's an unresponsive slab of grey pixels.

No good.

Pls push this into F26 ASAP.
Many thanks.
Comment 13 Andre Miranda editbugs 2017-09-12 04:43:12 CEST
Closing, the fix is available in thunar-1.6.12.
Thanks Viktor(ninetls)!
Comment 14 Skunnyk editbugs 2017-09-12 14:15:23 CEST
*** Bug 13472 has been marked as a duplicate of this bug. ***

Bug #13481

Reported by:
flocculant
Reported on: 2017-04-07
Last modified on: 2017-09-12
Duplicates (2):
  • 13472 Occasional freeze of thunar when file names are changed
  • 13500 Hang during shred operation

People

Assignee:
Xfce Bug Triage
CC List:
15 users

Version

Version:
1.6.11

Attachments

gdb trace (9.24 KB, application/octet-stream)
2017-04-07 10:55 CEST , flocculant
no flags
Deadlock fix (1.46 KB, patch)
2017-04-13 02:19 CEST , Viktor Odintsev
no flags

Additional information