[Mesa-dev] [Bug 105755] Mesa freezes when the GLSL shader contains a `for` loop with an uninitialized `i` index/counter variable

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Mon Mar 26 23:17:22 UTC 2018


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

            Bug ID: 105755
           Summary: Mesa freezes when the GLSL shader contains a `for`
                    loop with an uninitialized `i` index/counter variable
           Product: Mesa
           Version: unspecified
          Hardware: Other
                OS: All
            Status: NEW
          Severity: normal
          Priority: medium
         Component: Mesa core
          Assignee: mesa-dev at lists.freedesktop.org
          Reporter: swyterzone+mesa3d at gmail.com
        QA Contact: mesa-dev at lists.freedesktop.org

Created attachment 138364
  --> https://bugs.freedesktop.org/attachment.cgi?id=138364&action=edit
default.frag

So yeah, this has baffled me for a while. I have had reports of soft-locks and
freezes of my OpenGL/SDL2 game in Mesa-based Linux distros for a while, mainly
under Intel hardware. The game works fine in Windows and macOS using the same
shaders. Luckily I have just found out that it also happens under Nouveau, so
the problem seems to be at the GLSL parser-level or other shared/common
component.

After debugging the soft-locking issue for a bit it was clear that it only
happened whenever the dynamic point lights code path was in use. After
disabling and enabling it I suddenly realized something:

> for (int i; i < lightCount; i++)

I forgot to initialize the counter of the loop and that completely froze the
entire graphics pipeline, making the system unusable!


I find it funny that glslangValidator doesn't throw any error or warning even
if that should cause undefined behavior. Looks like the proprietary AMD and
NVIDIA OpenGL drivers initialize the `i` indexing variable to zero, which looks
like the sane thing to do.


It was my mistake, I'll try to lint them better. But the consequences are a bit
unforgiving.


PS: I'd attach an apitrace, but everything freezes. Let me know if you need
anything else, maybe we can give a bunch Steam keys to Mesa developers, in case
they are needed. The game is called Sphinx and the Cursed Mummy, a native
OpenGL 3+ port.

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


More information about the mesa-dev mailing list