Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • mesa mesa
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 2,870
    • Issues 2,870
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 894
    • Merge requests 894
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Mesa
  • mesamesa
  • Issues
  • #1024

Closed
Open
Created Sep 18, 2019 by Bugzilla Migration User@bugzilla-migration

Mesa freezes when the GLSL shader contains a `for` loop with an uninitialized `i` index/counter variable

Submitted by Swyter

Assigned to mes..@..op.org

Link to original bug (#105755)

Description

Created attachment 138364 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.

Attachment 138364, "default.frag":
default.frag

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking