<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 freezes when the GLSL shader contains a `for` loop with an uninitialized `i` index/counter variable"
href="https://bugs.freedesktop.org/show_bug.cgi?id=105755">105755</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Mesa freezes when the GLSL shader contains a `for` loop with an uninitialized `i` index/counter variable
</td>
</tr>
<tr>
<th>Product</th>
<td>Mesa
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>swyterzone+mesa3d@gmail.com
</td>
</tr>
<tr>
<th>QA Contact</th>
<td>mesa-dev@lists.freedesktop.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=138364" name="attach_138364" title="default.frag">attachment 138364</a> <a href="attachment.cgi?id=138364&action=edit" title="default.frag">[details]</a></span>
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:
<span class="quote">> for (int i; i < lightCount; i++)</span >
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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the QA Contact for the bug.</li>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>