Bug 71912 - Compounded macros in shaders: huge memory consumption
Summary: Compounded macros in shaders: huge memory consumption
Alias: None
Product: Mesa
Classification: Unclassified
Component: glsl-compiler (show other bugs)
Version: 9.1
Hardware: Other All
: medium normal
Assignee: Ian Romanick
QA Contact: Intel 3D Bugs Mailing List
Depends on:
Reported: 2013-11-22 11:01 UTC by Kevin Rogovin
Modified: 2019-09-18 19:45 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:

Vertex shader that has deep macro (2.41 KB, text/plain)
2013-11-22 11:01 UTC, Kevin Rogovin
paired fragment shader (1.33 KB, text/plain)
2013-11-22 11:01 UTC, Kevin Rogovin

Description Kevin Rogovin 2013-11-22 11:01:13 UTC
Created attachment 89625 [details]
Vertex shader that has deep macro

The attached shader causes literally gigabytes upon gigabytes of memory to be consumed when submitted to Mesa. The shader cause is because it compounds macros many levels deep. Mesa is at the stage of applying the preprocessor and does not get to even parsing the shader, much less compiling it.

The main issue is for WebGL enabled browsers. Indeed, a malicious website could submit such a shader (which is quite small) and bring the user's system to a standstill halt almost.

A possible fix is to essentially add additional logic to the preprocessor computing the complexity multiplier of a macro and if that complexity multiplies is too high to abort with a message that macro expands into a too large expression.
Comment 1 Kevin Rogovin 2013-11-22 11:01:38 UTC
Created attachment 89626 [details]
paired fragment shader
Comment 2 Kenneth Graunke 2013-11-22 11:18:07 UTC
Nice find.  Are you planning to try and fix this bug?
Comment 3 Kenneth Graunke 2013-11-22 11:19:43 UTC
Since this is a preprocessor issue, changing the component to glsl-compiler and reassigning to Carl as a default assignee.
Comment 4 GitLab Migration User 2019-09-18 19:45:15 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/mesa/mesa/issues/801.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.