After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 687470 - Deadlock in pangoxft-fontmap.c when closing an X connection
Deadlock in pangoxft-fontmap.c when closing an X connection
Status: RESOLVED FIXED
Product: pango
Classification: Platform
Component: general
1.32.x
Other Linux
: Normal normal
: ---
Assigned To: pango-maint
pango-maint
Depends on:
Blocks:
 
 
Reported: 2012-11-02 17:02 UTC by András Mohari
Modified: 2012-11-13 20:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to fix deadlock (567 bytes, patch)
2012-11-02 17:02 UTC, András Mohari
none Details | Review
A small program to demonstrate the problem (430 bytes, text/x-csrc)
2012-11-02 19:19 UTC, András Mohari
  Details

Description András Mohari 2012-11-02 17:02:16 UTC
Created attachment 227915 [details] [review]
Patch to fix deadlock

When trying to exit the Openbox window manager by running the openbox --exit command, it refuses to quit. A backtrace produced this:

  • #0 __kernel_vsyscall
  • #1 __lll_lock_wait
    from /usr/lib/libpthread.so.0
  • #2 _L_lock_675
    from /usr/lib/libpthread.so.0
  • #3 pthread_mutex_lock
    from /usr/lib/libpthread.so.0
  • #4 pthread_mutex_lock
    from /usr/lib/libc.so.6
  • #5 g_mutex_lock
    from /usr/lib/libglib-2.0.so.0
  • #6 ??
    from /usr/lib/libpangoxft-1.0.so.0
  • #7 pango_xft_shutdown_display
    from /usr/lib/libpangoxft-1.0.so.0
  • #8 ??
    from /usr/lib/libpangoxft-1.0.so.0
  • #9 XCloseDisplay
    from /usr/lib/libX11.so.6
  • #10 obt_display_close
    from /usr/lib/libobt.so.0
  • #11 main

(Sorry, see https://bugzilla.redhat.com/show_bug.cgi?id=802086#c6 for one with debug symbols.)

It seems that the close_display_cb() function that gets called when the X connection is closed calls pango_xft_shutdown_display() while holding a lock on the fontmaps. That function immediately calls pango_xft_find_font_map(), which itself tries to acquire a lock on the fontmaps, resulting in a deadlock.

The attached patch seems to fix this.
Comment 1 András Mohari 2012-11-02 19:19:58 UTC
Created attachment 227921 [details]
A small program to demonstrate the problem
Comment 2 András Mohari 2012-11-02 19:36:08 UTC
Comment on attachment 227921 [details]
A small program to demonstrate the problem

Here's a small program to demonstrate the bug. It should print "Closing display..." followed immediately by "Yay, display closed!", but the second one never gets printed as XCloseDisplay() can't return.
Comment 3 Michael D. Reiley 2012-11-06 23:37:08 UTC
I can confirm this bug and also confirm that the patch fixes it.
Comment 4 L33t 2012-11-13 17:29:24 UTC
This bug happens to me too.
Comment 5 Matthias Clasen 2012-11-13 20:13:38 UTC
Pushed a slightly different fix