<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Unreal Tournament (UT99) segfault on opengl init"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=108933#c6">Comment # 6</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Unreal Tournament (UT99) segfault on opengl init"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=108933">bug 108933</a>
              from <span class="vcard"><a class="email" href="mailto:iive@yahoo.com" title="iive@yahoo.com">iive@yahoo.com</a>
</span></b>
        <pre>Created <span class=""><a href="attachment.cgi?id=142752" name="attach_142752" title="Workaround for mesa crashing on UT99 because of static global constructor from C++ iostream">attachment 142752</a> <a href="attachment.cgi?id=142752&action=edit" title="Workaround for mesa crashing on UT99 because of static global constructor from C++ iostream">[details]</a></span> <a href='page.cgi?id=splinter.html&bug=108933&attachment=142752'>[review]</a>
Workaround for mesa crashing on UT99 because of static global constructor from
C++ iostream

Just few observations so far.

1.
I said that using libstdc++.so.24 gave different error. That's because I
replaced it after mesa compilation.
If mesa is compiled with g++-8.2 and libstdc++.so.24 it works with UT99.

2.
Another workaround is to remove completely all "include <iostream>".
There are 3 places where it is used.
"st_glsl_to_tgsi.cpp" and "st_glsl_to_tgsi_temprename.cpp" - for these just put
"#define NDEBUG 1" at the top of the files and all output would be disabled.
Things are more complicated for "st_glsl_to_tgsi_array_merge.cpp/h". The
debugging there is disabled by default, however not all printing functions are
cut out. So you need to add a bunch of extra #if/#endif to disable them. Note
that the header file also contains inline functions.
(Also, I'm with older LLVM, so if LLVM ever uses iostream, it may cause the
same problem.)

3.
As to why "include <iostream>" causes/triggers the problem.
A bit of googling turned out this problem:
<a href="https://isocpp.org/wiki/faq/ctors#static-init-order">https://isocpp.org/wiki/faq/ctors#static-init-order</a>

Static global constructors are called before main(). But their order is random.
If one depends on another, they could be called in the wrong order.

The "iosteam" has this line "static ios_base::Init __ioinit;". If it looks
familiar, you've seen it in the backtrace.

For now the main question is why it fails only with UT99 but not others. I
suspect that the problem may be linked to ldopen() usage and not loading
libstdc++ by the application. Unfortunately I'm having problem finding simple
sample demo programs that does that. (And even then, there might be something
more to it.)</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>