[Mesa-dev] [PATCH 1/3] glsl: on UBO/SSBOs link error, the number of active blocks remains 0

Andres Gomez agomez at igalia.com
Thu Mar 9 21:46:59 UTC 2017


On Fri, 2017-03-10 at 08:32 +1100, Timothy Arceri wrote:
> On 23/02/17 19:55, Andres Gomez wrote:
> > Commit f1293b2f9bc3 split apart buffer block arrays but introduced
> > also the possibility of a recount of active
> > blocks (NumUniformBlocks/NumShaderStorageBlocks) which would be
> > incoherent with the actual amount of active
> > blocks (UniformBlocks/ShaderStorageBlocks) in the program.
> > 
> > This could cause a segmentation fault if trying to use the index of a
> > block in a link failed program.
> 
> Where exactly does this segfault happen? 
> interstage_cross_validate_uniform_blocks() should exit linking because 
> we returned false.

It does exit, the segfault is not happening when running this code but
when using the link failed program later, as commented.

I caught this by using piglit's shader runner. In the "init_test"
function the last action is to call "setup_ubos":
https://cgit.freedesktop.org/piglit/tree/tests/shaders/shader_runner.c#n3704

This is done regardless the link status gotten previously. At
"setup_ubos" we ask first for the active UBOs:
https://cgit.freedesktop.org/piglit/tree/tests/shaders/shader_runner.c#n2652

And if there is any, we make use of them:
https://cgit.freedesktop.org/piglit/tree/tests/shaders/shader_runner.c#n2662

That's when the SIGSEV happens.

Of course, you could argue what are you doing using a link failed
program ☺ but the fact is that it should not return a value for the
active UBOs other than 0 and, most importantly, it shouldn't crash.

I hope this clarifies your doubt.

-- 
Br,

Andres


More information about the mesa-dev mailing list