<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 - driOpenDriver uses RTLD_GLOBAL and breaks clang's libc++"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=108669">108669</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>driOpenDriver uses RTLD_GLOBAL and breaks clang's libc++
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>18.0
          </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>stsp@list.ru
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>mesa-dev@lists.freedesktop.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>driOpenDriver() does this:
handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL)
When "realDriveName" == "radeonsi", we get libstdc++
loaded, because:

$ ldd /usr/lib64/dri/radeonsi_dri.so | grep libstdc++
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f2b2ee30000)

So this dri driver is linked with libstdc++.
RTLD_GLOBAL makes a problem when the main program
or some other lib is built with clang's libc++.
There happens to be a mix of symbols with same name,
and an imminent, hard to debug crash.
Please use RTLD_LOCAL to avoid the problem.

I've found this patch:
<a href="https://lists.freedesktop.org/archives/mesa-commit/2014-June/050035.html">https://lists.freedesktop.org/archives/mesa-commit/2014-June/050035.html</a>
which reverts to RTLD_GLOBAL in 3 places.
The problem is described here:
<a href="https://lists.freedesktop.org/archives/mesa-dev/2014-May/060441.html">https://lists.freedesktop.org/archives/mesa-dev/2014-May/060441.html</a>
Based on that description, I think it was enough
to use RTLD_GLOBAL only for "libGL.so.1", leaving
other places with RTLD_LOCAL.</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>