<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Joining threads stuck when forcefully closing all file descriptors"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=109777">109777</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Joining threads stuck when forcefully closing all file descriptors
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Mesa
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>18.3
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>x86-64 (AMD64)
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux (All)
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Drivers/DRI/i965
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>intel-3d-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>chrisito@gmx.de
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>intel-3d-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>thiago@kde.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I can always reproduce this by letting the IDE KDevelop crash and let the KDE
crash handler DrKonqi fire up.
Before DrKonqi is started, all file descriptors of KDevelop are closed. After
handling the crash, KDevelop may only exit once DrKonqi quit.
See <a href="https://phabricator.kde.org/D18245">https://phabricator.kde.org/D18245</a> for reference.

The situation I observe is that DrKonqi cannot quit because it remains stuck
waiting for something. The following backtraces are generated by pressing
Ctrl+C in gdb while the processes are stuck (which does not break the process
for now). The processes only receive the SIGINT signal (i.e. cease being
stuck), once the KDevelop process receives a SIGSTOP.

DrKonqi after being stuck:
======================

(gdb) info thread
  Id   Target Id                                           Frame
* 1    Thread 0x7f03d8a80cc0 (LWP 30318) "drkonqi"         0x00007f03dc9ebf6d
in __pthread_timedjoin_ex () from /usr/lib/libpthread.so.0
  3    Thread 0x7f03d5daa700 (LWP 30320) "QDBusConnection" 0x00007f03dd5aac21
in poll () from /usr/lib/libc.so.6
  4    Thread 0x7f03cf1a1700 (LWP 30327) "drkonqi:disk$0"  0x00007f03dc9f0afc
in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
(gdb) thread apply all bt

Thread 4 (Thread 0x7f03cf1a1700 (LWP 30327)):
#0  0x00007f03dc9f0afc in pthread_cond_wait@@GLIBC_2.3.2 () from
/usr/lib/libpthread.so.0
#1  0x00007f03cf5fcc94 in cnd_wait (mtx=0x55c99cfe0b88, cond=0x55c99cfe0bb0) at
../mesa-18.3.4/src/../include/c11/threads_posix.h:155
#2  util_queue_thread_func (input=input@entry=0x55c99d127b70) at
../mesa-18.3.4/src/util/u_queue.c:270
#3  0x00007f03cf5fc9b8 in impl_thrd_routine (p=<optimized out>) at
../mesa-18.3.4/src/../include/c11/threads_posix.h:87
#4  0x00007f03dc9eaa9d in start_thread () from /usr/lib/libpthread.so.0
#5  0x00007f03dd5b5b23 in clone () from /usr/lib/libc.so.6

Thread 3 (Thread 0x7f03d5daa700 (LWP 30320)):
#0  0x00007f03dd5aac21 in poll () from /usr/lib/libc.so.6
#1  0x00007f03db9a8540 in ?? () from /usr/lib/libglib-2.0.so.0
#2  0x00007f03db9a862e in g_main_context_iteration () from
/usr/lib/libglib-2.0.so.0
#3  0x00007f03ddc7cce9 in
QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
from /usr/lib/libQt5Core.so.5
#4  0x00007f03ddc25b2c in
QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from
/usr/lib/libQt5Core.so.5
#5  0x00007f03dda69569 in QThread::exec() () from /usr/lib/libQt5Core.so.5
#6  0x00007f03deb62ba6 in ?? () from /usr/lib/libQt5DBus.so.5
#7  0x00007f03dda6a96c in ?? () from /usr/lib/libQt5Core.so.5
#8  0x00007f03dc9eaa9d in start_thread () from /usr/lib/libpthread.so.0
#9  0x00007f03dd5b5b23 in clone () from /usr/lib/libc.so.6

Thread 1 (Thread 0x7f03d8a80cc0 (LWP 30318)):
#0  0x00007f03dc9ebf6d in __pthread_timedjoin_ex () from
/usr/lib/libpthread.so.0
#1  0x00007f03cf5fca71 in thrd_join (res=0x0, thr=<optimized out>) at
../mesa-18.3.4/src/../include/c11/threads_posix.h:329
#2  util_queue_killall_and_wait (queue=queue@entry=0x55c99cfe0b50) at
../mesa-18.3.4/src/util/u_queue.c:431
#3  0x00007f03cf5fd309 in util_queue_destroy (queue=0x55c99cfe0b50) at
../mesa-18.3.4/src/util/u_queue.c:438
#4  0x00007f03cf5f873a in disk_cache_destroy (cache=0x55c99cfe0b40) at
../mesa-18.3.4/src/util/disk_cache.c:439
#5  0x00007f03cf582344 in intelDestroyScreen (sPriv=0x55c99d0541a0) at
../mesa-18.3.4/src/mesa/drivers/dri/i965/intel_screen.c:1674
#6  0x00007f03cf5f43cf in driDestroyScreen (psp=0x55c99d0541a0) at
../mesa-18.3.4/src/mesa/drivers/dri/common/dri_util.c:231
#7  0x00007f03d466307c in dri3_destroy_screen (base=0x55c99d023b70) at
../mesa-18.3.4/src/glx/dri3_glx.c:609
#8  0x00007f03d464f822 in FreeScreenConfigs (priv=<optimized out>,
priv=<optimized out>) at ../mesa-18.3.4/src/glx/glxext.c:221
#9  0x00007f03d464f8a9 in glx_display_free (priv=0x55c99d09ae00) at
../mesa-18.3.4/src/glx/glxext.c:244
#10 0x00007f03d464f9fe in __glXCloseDisplay (dpy=0x55c99cea1050,
codes=<optimized out>) at ../mesa-18.3.4/src/glx/glxext.c:299
#11 0x00007f03dcc993e2 in XCloseDisplay () from /usr/lib/libX11.so.6
#12 0x00007f03d85cff52 in ?? () from /usr/lib/libQt5XcbQpa.so.5
#13 0x00007f03d85a511a in QXcbConnection::~QXcbConnection() () from
/usr/lib/libQt5XcbQpa.so.5
#14 0x00007f03d85a63d7 in QXcbIntegration::~QXcbIntegration() () from
/usr/lib/libQt5XcbQpa.so.5
#15 0x00007f03d85a64da in QXcbIntegration::~QXcbIntegration() () from
/usr/lib/libQt5XcbQpa.so.5
#16 0x00007f03ddff0ed9 in QGuiApplicationPrivate::~QGuiApplicationPrivate() ()
from /usr/lib/libQt5Gui.so.5
#17 0x00007f03de5ef6fa in QApplicationPrivate::~QApplicationPrivate() () from
/usr/lib/libQt5Widgets.so.5
#18 0x00007f03ddc5886f in QObject::~QObject() () from /usr/lib/libQt5Core.so.5
#19 0x00007f03ddc292b0 in QCoreApplication::~QCoreApplication() () from
/usr/lib/libQt5Core.so.5
#20 0x00007f03de5f1842 in QApplication::~QApplication() () from
/usr/lib/libQt5Widgets.so.5
#21 0x000055c99b641e23 in main ()

======================

Running threads in KDevelop (I removed some unrelated threads):
======================

(gdb) info thread
  Id   Target Id                                           Frame
* 1    Thread 0x7f9cfcaed440 (LWP 29609) "kdevelop"        0x00007f9d11185c21
in poll () from /usr/lib/libc.so.6
  2    Thread 0x7f9cfbd34700 (LWP 29610) "QXcbEventQueue"  0x00007f9d11185c21
in poll () from /usr/lib/libc.so.6
  3    Thread 0x7f9cf9b1b700 (LWP 29611) "kdevelo:disk$0"  0x00007f9d103e2afc
in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
  4    Thread 0x7f9cf3d13700 (LWP 29612) "QDBusConnection" 0x00007f9d0e9013b9
in g_mutex_lock () from /usr/lib/libglib-2.0.so.0
  5    Thread 0x7f9cf16d5700 (LWP 29613) "QThread"         0x00007f9d11185c21
in poll () from /usr/lib/libc.so.6
  6    Thread 0x7f9cdffff700 (LWP 29620) "kdevelop"        0x00007f9d103e2afc
in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
  7    Thread 0x7f9cdef6f700 (LWP 29621) "QQmlThread"      0x00007f9d11646c87
in ?? () from /usr/lib/libQt5Core.so.5
  8    Thread 0x7f9cdcb46700 (LWP 29623) "KDevelop::Compl" 0x00007f9d11185c39
in poll () from /usr/lib/libc.so.6
  9    Thread 0x7f9cd7eb8700 (LWP 29624) "OutputFilterThr" 0x00007f9d0e9013b9
in g_mutex_lock () from /usr/lib/libglib-2.0.so.0
  10   Thread 0x7f9cd7436700 (LWP 29626) "Qt bearer threa" 0x00007f9d11185c21
in poll () from /usr/lib/libc.so.6
  11   Thread 0x7f9cd6546700 (LWP 29630) "KDevelop::Compl" 0x00007f9d0e901420
in g_mutex_unlock () from /usr/lib/libglib-2.0.so.0
  12   Thread 0x7f9cbaffd700 (LWP 30235) "QQuickXmlQueryE" 0x00007f9d111817a4
in read () from /usr/lib/libc.so.6
  13   Thread 0x7f9cb97fa700 (LWP 30260) "Queue(0x55b7cd8" 0x00007f9d103e2afc
in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
  14   Thread 0x7f9cd4bc7700 (LWP 30261) "Queue(0x55b7cd8" 0x00007f9d103e2afc
in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
  15   Thread 0x7f9cbbfff700 (LWP 30262) "Queue(0x55b7cd8" 0x00007f9d103e2afc
in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
  16   Thread 0x7f9cbb7fe700 (LWP 30263) "Queue(0x55b7cd8" 0x00007f9d103e2afc
in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
  17   Thread 0x7f9cba7fc700 (LWP 30264) "Queue(0x55b7cd8" 0x00007f9d103e2afc
in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
(gdb) thread apply all bt

Thread 4 (Thread 0x7f9cf3d13700 (LWP 29612)):
#0  0x00007f9d0e9013b9 in g_mutex_lock () at /usr/lib/libglib-2.0.so.0
#1  0x00007f9d0e951fbe in g_main_context_check () at /usr/lib/libglib-2.0.so.0
#2  0x00007f9d0e9534e6 in  () at /usr/lib/libglib-2.0.so.0
#3  0x00007f9d0e95362e in g_main_context_iteration () at
/usr/lib/libglib-2.0.so.0
#4  0x00007f9d11859d04 in
QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
at /usr/lib/libQt5Core.so.5
#5  0x00007f9d11802b2c in
QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at
/usr/lib/libQt5Core.so.5
#6  0x00007f9d11646569 in QThread::exec() () at /usr/lib/libQt5Core.so.5
#7  0x00007f9d123b2ba6 in  () at /usr/lib/libQt5DBus.so.5
#8  0x00007f9d1164796c in  () at /usr/lib/libQt5Core.so.5
#9  0x00007f9d103dca9d in start_thread () at /usr/lib/libpthread.so.0
#10 0x00007f9d11190b23 in clone () at /usr/lib/libc.so.6

Thread 3 (Thread 0x7f9cf9b1b700 (LWP 29611)):
#0  0x00007f9d103e2afc in pthread_cond_wait@@GLIBC_2.3.2 () at
/usr/lib/libpthread.so.0
#1  0x00007f9cfa12dc94 in cnd_wait (mtx=0x55b7ccf1f4b8, cond=0x55b7ccf1f4e0) at
../mesa-18.3.4/src/../include/c11/threads_posix.h:155
#2  0x00007f9cfa12dc94 in util_queue_thread_func
(input=input@entry=0x55b7ccf51990) at ../mesa-18.3.4/src/util/u_queue.c:270
#3  0x00007f9cfa12d9b8 in impl_thrd_routine (p=<optimized out>) at
../mesa-18.3.4/src/../include/c11/threads_posix.h:87
#4  0x00007f9d103dca9d in start_thread () at /usr/lib/libpthread.so.0
#5  0x00007f9d11190b23 in clone () at /usr/lib/libc.so.6

Thread 2 (Thread 0x7f9cfbd34700 (LWP 29610)):
#0  0x00007f9d11185c21 in poll () at /usr/lib/libc.so.6
#1  0x00007f9d078fd630 in  () at /usr/lib/libxcb.so.1
#2  0x00007f9d078ff2db in xcb_wait_for_event () at /usr/lib/libxcb.so.1
#3  0x00007f9cfc637949 in  () at /usr/lib/libQt5XcbQpa.so.5
#4  0x00007f9d1164796c in  () at /usr/lib/libQt5Core.so.5
#5  0x00007f9d103dca9d in start_thread () at /usr/lib/libpthread.so.0
#6  0x00007f9d11190b23 in clone () at /usr/lib/libc.so.6

Thread 1 (Thread 0x7f9cfcaed440 (LWP 29609)):
#0  0x00007f9d11185c21 in poll () at /usr/lib/libc.so.6
#1  0x00007f9d12e31edb in pollDrKonqiSocket(int, int) () at
/home/christoph/kde-latest/lib64/libKF5Crash.so.5
#2  0x00007f9d12e3156b in startProcessInternal(int, char const**, bool, bool)
() at /home/christoph/kde-latest/lib64/libKF5Crash.so.5
#3  0x00007f9d12e31275 in KCrash::startProcess(int, char const**, bool) () at
/home/christoph/kde-latest/lib64/libKF5Crash.so.5
#4  0x00007f9d12e3115c in KCrash::defaultCrashHandler(int) () at
/home/christoph/kde-latest/lib64/libKF5Crash.so.5
#5  0x00007f9d110cce00 in <signal handler called> () at /usr/lib/libc.so.6
#6  0x00007f9d11185c21 in poll () at /usr/lib/libc.so.6
#7  0x00007f9d0e953540 in  () at /usr/lib/libglib-2.0.so.0
#8  0x00007f9d0e95362e in g_main_context_iteration () at
/usr/lib/libglib-2.0.so.0
#9  0x00007f9d11859ce9 in
QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
at /usr/lib/libQt5Core.so.5
#10 0x00007f9d11802b2c in
QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at
/usr/lib/libQt5Core.so.5
#11 0x00007f9d1180ae36 in QCoreApplication::exec() () at
/usr/lib/libQt5Core.so.5
#12 0x000055b7cb0ec398 in main ()

======================

Interestingly 3rd applications such as glxgears cannot quit either while
KDevelop remains. It's stuck after closing the window:
======================

(gdb) info thread
  Id   Target Id                                          Frame 
* 1    Thread 0x7ffff74ed740 (LWP 26680) "glxgears"       0x00007ffff772ff6d in
__pthread_timedjoin_ex () from /usr/lib/libpthread.so.0
  2    Thread 0x7ffff59f1700 (LWP 26690) "glxgear:disk$0" 0x00007ffff7734afc in
pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
(gdb) thread apply all bt

Thread 2 (Thread 0x7ffff59f1700 (LWP 26690)):
#0  0x00007ffff7734afc in pthread_cond_wait@@GLIBC_2.3.2 () from
/usr/lib/libpthread.so.0
#1  0x00007ffff63a0c94 in cnd_wait (mtx=0x5555558c0ee8, cond=0x5555558c0f10) at
../mesa-18.3.4/src/../include/c11/threads_posix.h:155
#2  util_queue_thread_func (input=input@entry=0x5555557ab000) at
../mesa-18.3.4/src/util/u_queue.c:270
#3  0x00007ffff63a09b8 in impl_thrd_routine (p=<optimized out>) at
../mesa-18.3.4/src/../include/c11/threads_posix.h:87
#4  0x00007ffff772ea9d in start_thread () from /usr/lib/libpthread.so.0
#5  0x00007ffff7b4bb23 in clone () from /usr/lib/libc.so.6

Thread 1 (Thread 0x7ffff74ed740 (LWP 26680)):
#0  0x00007ffff772ff6d in __pthread_timedjoin_ex () from
/usr/lib/libpthread.so.0
#1  0x00007ffff63a0a71 in thrd_join (res=0x0, thr=<optimized out>) at
../mesa-18.3.4/src/../include/c11/threads_posix.h:329
#2  util_queue_killall_and_wait (queue=queue@entry=0x5555558c0eb0) at
../mesa-18.3.4/src/util/u_queue.c:431
#3  0x00007ffff63a0ae8 in atexit_handler () at
../mesa-18.3.4/src/util/u_queue.c:57
#4  0x00007ffff7a8a45c in __run_exit_handlers () from /usr/lib/libc.so.6
#5  0x00007ffff7a8a58e in exit () from /usr/lib/libc.so.6
#6  0x00007ffff7c5739a in _XDefaultIOError () from /usr/lib/libX11.so.6
#7  0x00007ffff7c575ce in _XIOError () from /usr/lib/libX11.so.6
#8  0x00007ffff7c54e3f in _XEventsQueued () from /usr/lib/libX11.so.6
#9  0x00007ffff7c46998 in XPending () from /usr/lib/libX11.so.6
#10 0x0000555555555bc1 in ?? ()
#11 0x00007ffff7a74223 in __libc_start_main () from /usr/lib/libc.so.6
#12 0x000055555555608a in ?? ()

======================

glxinfo:
======================

name of display: :0
display: :0  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Intel Open Source Technology Center (0x8086)
    Device: Mesa DRI Intel(R) HD Graphics 630 (Kaby Lake GT2)  (0x5912)
    Version: 18.3.4
    Accelerated: yes
    Video memory: 3072MB
    Unified memory: yes
    Preferred profile: core (0x1)
    Max core profile version: 4.5
    Max compat profile version: 3.0
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.2
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 630 (Kaby Lake GT2) 
OpenGL core profile version string: 4.5 (Core Profile) Mesa 18.3.4
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 3.0 Mesa 18.3.4
OpenGL shading language version string: 1.30
OpenGL context flags: (none)

OpenGL ES profile version string: OpenGL ES 3.2 Mesa 18.3.4
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the QA Contact for the bug.</li>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>