[Mesa-dev] [Bug 108933] Unreal Tournament (UT99) segfault on opengl init

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Sat Dec 8 14:51:41 UTC 2018


https://bugs.freedesktop.org/show_bug.cgi?id=108933

--- Comment #6 from iive at yahoo.com ---
Created attachment 142752
  --> https://bugs.freedesktop.org/attachment.cgi?id=142752&action=edit
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:
https://isocpp.org/wiki/faq/ctors#static-init-order

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.)

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are the QA Contact for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20181208/d99ceea7/attachment.html>


More information about the mesa-dev mailing list