On 02/11/2013 07:19 PM, Eric Anholt wrote:
Brian Paul<bri...@vmware.com>  writes:

Google Earth v7 calls glReleaseShaderCompiler() and Mesa's GLSL
compiler is crashing.

In particular, it looks like glReleaseShaderCompiler() is getting
called between glCompileShader() and glLinkProgram().  The
glLinkProgram() call crashes when we try to reference some data
structures which were freed by glReleaseShaderCompiler().

Here's an example from valgrind:

==10049== Invalid read of size 4
==10049==    at 0x14FE4B9C: ir_call::ir_call(ir_function_signature*,
ir_dereference_variable*, exec_list*) (ir.h:1135)
==10049==    by 0x14FEC269: ir_call::clone(void*, hash_table*) const
(ir_clone.cpp:181)
==10049==    by 0x14FEC97A: ir_function_signature::clone(void*,
hash_table*) const (ir_clone.cpp:313)
==10049==    by 0x14FEC8A3: ir_function::clone(void*, hash_table*)
const (ir_clone.cpp:290)
==10049==    by 0x14FECDDA: clone_ir_list(void*, exec_list*, exec_list
const*) (ir_clone.cpp:433)
==10049==    by 0x14F0750C: link_intrastage_shaders(void*,
gl_context*, gl_shader_program*, gl_shader**, unsigned int)
(linker.cpp:1062)
==10049==    by 0x14F09B5E: link_shaders(gl_context*,
gl_shader_program*) (linker.cpp:2471)
==10049==    by 0x1500064C: _mesa_glsl_link_shader (ir_to_mesa.cpp:3155)
==10049==    by 0x14F96F36: link_program (shaderapi.c:758)
==10049==    by 0x14F98165: _mesa_LinkProgram (shaderapi.c:1254)
==10049==    by 0x8927796:
Gap::Gfx::GL2VertexShader::LinkPixelShader(unsigned int) (in
/opt/google/earth/free/libIGGfx.so)
==10049==    by 0x893F9B2:
Gap::Gfx::GL2VertexShader::bind(Gap::Gfx::igOglVisualContext*) (in
/opt/google/earth/free/libIGGfx.so)
==10049==  Address 0x8fd6cf0 is 40 bytes inside a block of size 80 free'd
==10049==    at 0x402768C: free (in
/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==10049==    by 0x14EFB640: unsafe_free (ralloc.c:245)
==10049==    by 0x14EFB610: unsafe_free (ralloc.c:238)
==10049==    by 0x14EFB610: unsafe_free (ralloc.c:238)
==10049==    by 0x14EFB55B: ralloc_free (ralloc.c:208)
==10049==    by 0x14F02BB3: _mesa_glsl_release_functions()
(builtin_function.cpp:14643)
==10049==    by 0x14EE7D95: _mesa_destroy_shader_compiler_caches
(glsl_parser_extras.cpp:1101)
==10049==    by 0x14F987CC: _mesa_ReleaseShaderCompiler (shaderapi.c:1491)
==10049==    by 0x891206C:
Gap::Gfx::GL2Shader::CompileShader(Gap::Gfx::igOglVisualContext*,
unsigned int, char const*) (in /opt/google/earth/free/libIGGfx.so)
==10049==    by 0x89470A5:
Gap::Gfx::GL2VertexShader::CreateVertexShader(Gap::Gfx::igOglVisualContext*,
char const*, Gap::Gfx::igVertexDataList const*,
Gap::Gfx::igGfxShaderConstantList const*) (in
/opt/google/earth/free/libIGGfx.so)
==10049==    by 0x894EC64:
Gap::Gfx::igOglVisualContext::createVertexShader_GL2(char const*,
Gap::Gfx::igVertexDataList const*, Gap::Gfx::igGfxShaderConstantList
const*) (in /opt/google/earth/free/libIGGfx.so)
==10049==    by 0x8916479:
Gap::Gfx::igOglVisualContext::createVertexShader_OGL(char const*,
Gap::Gfx::IG_GFX_SHADER_LANGUAGE, Gap::Gfx::igVertexDataList const*,
Gap::Gfx::igGfxShaderConstantList const*, char const*, char const*,
Gap::Gfx::igGfxShaderDefineList const*) (in
/opt/google/earth/free/libIGGfx.so)
==10049==


I've hacked several other Mesa GLSL tests to call
glReleaseShaderCompiler() between compile and link and get similar
results.

Can someone look into fixing this?

I just noticed this mail still marked todo, and I don't see a fix having
landed.  I wrote up a piglit test that failed to reproduce this.  Can
you write one?

I did. :)

I tried to repro this with some simple shaders, but it appears that larger shaders or particular shader features are needed.

I found that this patch to mesa mandelbrot demo reproduces the problem:

diff --git a/src/glsl/mandelbrot.c b/src/glsl/mandelbrot.c
index 31ede1d..7f19e9d 100644
--- a/src/glsl/mandelbrot.c
+++ b/src/glsl/mandelbrot.c
@@ -155,6 +155,7 @@ Init(void)

    vertShader = CompileShaderFile(GL_VERTEX_SHADER, VertProgFile);
    fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
+   glReleaseShaderCompiler();
    program = LinkShaders(vertShader, fragShader);

    glUseProgram(program);


-Brian

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to