<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 - Mesa CANNOT use libpthread-stubs"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=98048">98048</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Mesa CANNOT use libpthread-stubs
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>git
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>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>Mesa core
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>mesa-dev@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>idr@freedesktop.org
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>mesa-dev@lists.freedesktop.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>At least as far back as ecaa81b, Mesa has used pthread_mutexattr_init and
pthread_mutexattr_settype.  Neither of these functions is available in libc6,
so both are supplied by libpthread-stubs.  However, the implementations in
libpthread-stubs don't do anything.  That's a huge problem because
pthread_mutex_init expects that pthread_mutexattr_t to contain valid data.

I have observed two adverse affects of this in piglit runs on multiple systems.

1. On softpipe, there are numerous sporadic crashes inside malloc or free (see
file:///home/idr/devel/graphics/piglit-results/results/problems.html).  There
are also numerous valgrind warnings like:

==27195== Conditional jump or move depends on uninitialised value(s)
==27195==    at 0x99E82A2: pthread_mutex_init (in
/usr/lib64/libpthread-2.22.so)
==27195==    by 0xBA9EA1D: mtx_init (threads_posix.h:217)
==27195==    by 0xBA9EA1D: _mesa_alloc_shared_state (shared.c:122)
==27195==    by 0xB9DA749: _mesa_initialize_context (context.c:1188)
==27195==    by 0xBB4478F: st_create_context (st_context.c:544)
==27195==    by 0xBB6C64D: st_api_create_context (st_manager.c:669)
==27195==    by 0xBCA6DD6: dri_create_context (dri_context.c:123)
==27195==    by 0xBCA63EE: driCreateContextAttribs (dri_util.c:448)
==27195==    by 0x52515E8: drisw_create_context_attribs (drisw_glx.c:476)
==27195==    by 0x522B5A2: glXCreateContextAttribsARB (create_context.c:78)
==27195==    by 0x6413353: ??? (in /usr/lib64/libwaffle-1.so.0.5.0)
==27195==    by 0x640F394: waffle_context_create (in
/usr/lib64/libwaffle-1.so.0.5.0)
==27195==    by 0x4F72238: make_context_current_singlepass
(piglit_wfl_framework.c:476)


2. On NV20 I have observed semi-random deadlocks from within meta.  I have a
patch to work around these, but I now believe the real problem is the context
shared texture mutex is not being created PTHREAD_MUTEX_RECURSIVE because
pthread_mutexattr_settype does nothing.

piglit tests link with libpthread.  I have confirmed that the versions from
libpthread-stubs are still called from within Mesa:

[idr@dynamic104 piglit]$ LIBGL_ALWAYS_SOFTWARE=y gdb --args bin/asmparsertest
ARBvp1.0 tests/asmparsertest/shaders/ARBvp1.0/sne-02.txt -auto -fbo
GNU gdb (GDB) Fedora 7.10.1-31.fc23
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <<a href="http://gnu.org/licenses/gpl.html">http://gnu.org/licenses/gpl.html</a>>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<<a href="http://www.gnu.org/software/gdb/bugs/">http://www.gnu.org/software/gdb/bugs/</a>>.
Find the GDB manual and other documentation resources online at:
<<a href="http://www.gnu.org/software/gdb/documentation/">http://www.gnu.org/software/gdb/documentation/</a>>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from bin/asmparsertest...done.
(gdb) b pthread_mutexattr_init
Function "pthread_mutexattr_init" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (pthread_mutexattr_init) pending.
(gdb) r
Starting program: /home/idr/devel/graphics/piglit/bin/asmparsertest ARBvp1.0
/home/idr/devel/graphics/piglit/tests/asmparsertest/shaders/ARBvp1.0/sne-02.txt
-auto -fbo
Missing separate debuginfos, use: dnf debuginfo-install
glibc-2.22-18.fc23.x86_64
warning: Unable to find libthread_db matching inferior's thread library, thread
debugging will not be available.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
couldn't open libtxc_dxtn.so, software DXTn compression/decompression
unavailable

Breakpoint 1, __pthread_zero_stub () at stubs.c:203
203     }
(gdb) bt
#0  __pthread_zero_stub () at stubs.c:203
#1  0x00007ffff0fb6a06 in mtx_init (type=4, mtx=0x6fb9d8) at
../../include/c11/threads_posix.h:215
#2  _mesa_alloc_shared_state (ctx=ctx@entry=0x7ffff7fd0010) at
main/shared.c:122
#3  0x00007ffff0ef274a in _mesa_initialize_context
(ctx=ctx@entry=0x7ffff7fd0010, api=api@entry=API_OPENGL_COMPAT,
visual=visual@entry=0x7fffffffd140, share_list=share_list@entry=0x0,
driverFunctions=driverFunctions@entry=0x7fffffffcbe0) at main/context.c:1188
#4  0x00007ffff105c790 in st_create_context (api=api@entry=API_OPENGL_COMPAT,
pipe=pipe@entry=0x63a2e0, visual=visual@entry=0x7fffffffd140,
share=share@entry=0x0, options=options@entry=0x7fffffffd278) at
state_tracker/st_context.c:544
#5  0x00007ffff108464e in st_api_create_context (stapi=<optimized out>,
smapi=0x62ad00, attribs=0x7fffffffd250, error=0x7fffffffd24c,
shared_stctxi=0x0) at state_tracker/st_manager.c:669
#6  0x00007ffff11bedd7 in dri_create_context (api=<optimized out>,
visual=0x62f870, cPriv=<optimized out>, major_version=<optimized out>,
minor_version=<optimized out>, flags=<optimized out>, notify_reset=false,
error=0x7fffffffd3fc, sharedContextPrivate=0x0) at dri_context.c:123
#7  0x00007ffff11be3ef in driCreateContextAttribs (screen=0x62ac60,
api=<optimized out>, config=<optimized out>, shared=<optimized out>,
num_attribs=<optimized out>, attribs=<optimized out>, error=0x7fffffffd3fc,
data=0x623070) at dri_util.c:448
#8  0x00007ffff77d05e9 in drisw_create_context_attribs (base=0x622f70,
config_base=0x637040, shareList=<optimized out>, num_attribs=<optimized out>,
attribs=<optimized out>, error=0x7fffffffd3fc) at drisw_glx.c:476
#9  0x00007ffff77aa5a3 in glXCreateContextAttribsARB (dpy=0x615390,
config=0x637040, share_context=0x0, direct=1, attrib_list=0x7fffffffd450) at
create_context.c:78
#10 0x00007ffff65fc354 in glx_context_create () from /lib64/libwaffle-1.so.0
#11 0x00007ffff65f8395 in waffle_context_create () from /lib64/libwaffle-1.so.0
#12 0x00007ffff7b3c239 in make_context_current_singlepass (wfl_fw=0x614c40,
test_config=0x7fffffffdb50, flavor=CONTEXT_GL_COMPAT,
partial_config_attrib_list=0x0) at
tests/util/piglit-framework-gl/piglit_wfl_framework.c:476
#13 0x00007ffff7b3c4f1 in make_context_current (wfl_fw=0x614c40,
test_config=0x7fffffffdb50, partial_config_attrib_list=0x0) at
tests/util/piglit-framework-gl/piglit_wfl_framework.c:557
#14 0x00007ffff7b3c5ea in piglit_wfl_framework_init (wfl_fw=0x614c40,
test_config=0x7fffffffdb50, platform=19, partial_config_attrib_list=0x0) at
tests/util/piglit-framework-gl/piglit_wfl_framework.c:613
#15 0x00007ffff7b3b1ae in piglit_fbo_framework_create
(test_config=0x7fffffffdb50) at
tests/util/piglit-framework-gl/piglit_fbo_framework.c:151
#16 0x00007ffff7b216e2 in piglit_gl_framework_factory
(test_config=0x7fffffffdb50) at
tests/util/piglit-framework-gl/piglit_gl_framework.c:48
#17 0x00007ffff7b2125d in piglit_gl_test_run (argc=3, argv=0x7fffffffdc88,
config=0x7fffffffdb50) at tests/util/piglit-framework-gl.c:191
#18 0x000000000040127e in main (argc=3, argv=0x7fffffffdc88) at
tests/asmparsertest/asmparsertest.c:41</pre>
        </div>
      </p>


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

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