Bug 45082 - "ralloc.c:78: get_header: Assertion `info->canary == 0x5A1106' failed." when using a macro in GLSL
Summary: "ralloc.c:78: get_header: Assertion `info->canary == 0x5A1106' failed." when ...
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: glsl-compiler (show other bugs)
Version: 7.11
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Carl Worth
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-22 06:28 UTC by David Lerch
Modified: 2012-02-02 13:33 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Test program compiling the mentioned shader. It depends on GL, GLEW and SDL (1.17 KB, application/x-gzip)
2012-01-22 06:28 UTC, David Lerch
Details

Description David Lerch 2012-01-22 06:28:34 UTC
Created attachment 55958 [details]
Test program compiling the mentioned shader. It depends on GL, GLEW and SDL

Compiling the following simple (and incomplete, but that shouldn't matter) vertex shader in Mesa 7.11.2 fails:


#define RANDOMNAME(a) (2>(a))
#if RANDOMNAME(3)
#endif
#if RANDOMNAME(3)
#endif


This produces the following error message when it is compiled:


ralloc.c:78: get_header: Assertion `info->canary == 0x5A1106' failed.


I've run the attached test program in Valgrind, and it complains with a lot of messages similar to these:


==17959== Invalid read of size 4
==17959==    at 0x4E63B4D: _glcpp_parser_expand_token_list (glcpp-parse.y:1392)
==17959==    by 0x4E63D5E: _glcpp_parser_expand_if (glcpp-parse.y:1271)
==17959==    by 0x4E653FE: yyparse (glcpp-parse.y:237)
==17959==    by 0x4DB43B4: preprocess (pp.c:152)
==17959==    by 0x4DB2F52: _mesa_glsl_compile_shader (ir_to_mesa.cpp:3191)
==17959==    by 0x401305: CompileShaderProgram(char const*, char const*) (in /home/alemariusnexus/test/gltest/gltest)
==17959==    by 0x401625: main (in /home/alemariusnexus/test/gltest/gltest)
==17959==  Address 0xcb5c7a0 is 48 bytes inside a block of size 88 free'd
==17959==    at 0x4A0662E: free (vg_replace_malloc.c:366)
==17959==    by 0x4DB378C: unsafe_free (ralloc.c:235)
==17959==    by 0x4E65E69: yyparse (glcpp-parse.y:1817)
==17959==    by 0x4DB43B4: preprocess (pp.c:152)
==17959==    by 0x4DB2F52: _mesa_glsl_compile_shader (ir_to_mesa.cpp:3191)
==17959==    by 0x401305: CompileShaderProgram(char const*, char const*) (in /home/alemariusnexus/test/gltest/gltest)
==17959==    by 0x401625: main (in /home/alemariusnexus/test/gltest/gltest)
==17959== 
==17959== Invalid read of size 4
==17959==    at 0x4DB37B4: get_header (ralloc.c:78)
==17959==    by 0x4DB3AF5: ralloc_steal (ralloc.c:253)
==17959==    by 0x4E62D9B: _token_list_append (glcpp-parse.y:766)
==17959==    by 0x4E63C7C: _glcpp_parser_expand_token_list (glcpp-parse.y:1420)
==17959==    by 0x4E63D5E: _glcpp_parser_expand_if (glcpp-parse.y:1271)
==17959==    by 0x4E653FE: yyparse (glcpp-parse.y:237)
==17959==    by 0x4DB43B4: preprocess (pp.c:152)
==17959==    by 0x4DB2F52: _mesa_glsl_compile_shader (ir_to_mesa.cpp:3191)
==17959==    by 0x401305: CompileShaderProgram(char const*, char const*) (in /home/alemariusnexus/test/gltest/gltest)
==17959==    by 0x401625: main (in /home/alemariusnexus/test/gltest/gltest)
==17959==  Address 0xcb5c770 is 0 bytes inside a block of size 88 free'd
==17959==    at 0x4A0662E: free (vg_replace_malloc.c:366)
==17959==    by 0x4DB378C: unsafe_free (ralloc.c:235)
==17959==    by 0x4E65E69: yyparse (glcpp-parse.y:1817)
==17959==    by 0x4DB43B4: preprocess (pp.c:152)
==17959==    by 0x4DB2F52: _mesa_glsl_compile_shader (ir_to_mesa.cpp:3191)
==17959==    by 0x401305: CompileShaderProgram(char const*, char const*) (in /home/alemariusnexus/test/gltest/gltest)
==17959==    by 0x401625: main (in /home/alemariusnexus/test/gltest/gltest)
==17959== 
==17959== Invalid read of size 8
==17959==    at 0x4DB3B01: ralloc_steal (ralloc.c:212)
==17959==    by 0x4E62D9B: _token_list_append (glcpp-parse.y:766)
==17959==    by 0x4E63C7C: _glcpp_parser_expand_token_list (glcpp-parse.y:1420)
==17959==    by 0x4E63D5E: _glcpp_parser_expand_if (glcpp-parse.y:1271)
==17959==    by 0x4E653FE: yyparse (glcpp-parse.y:237)
==17959==    by 0x4DB43B4: preprocess (pp.c:152)
==17959==    by 0x4DB2F52: _mesa_glsl_compile_shader (ir_to_mesa.cpp:3191)
==17959==    by 0x401305: CompileShaderProgram(char const*, char const*) (in /home/alemariusnexus/test/gltest/gltest)
==17959==    by 0x401625: main (in /home/alemariusnexus/test/gltest/gltest)
==17959==  Address 0xcb5c778 is 8 bytes inside a block of size 88 free'd
==17959==    at 0x4A0662E: free (vg_replace_malloc.c:366)
==17959==    by 0x4DB378C: unsafe_free (ralloc.c:235)
==17959==    by 0x4E65E69: yyparse (glcpp-parse.y:1817)
==17959==    by 0x4DB43B4: preprocess (pp.c:152)
==17959==    by 0x4DB2F52: _mesa_glsl_compile_shader (ir_to_mesa.cpp:3191)
==17959==    by 0x401305: CompileShaderProgram(char const*, char const*) (in /home/alemariusnexus/test/gltest/gltest)
==17959==    by 0x401625: main (in /home/alemariusnexus/test/gltest/gltest)
Comment 1 Carl Worth 2012-02-02 13:33:27 UTC
This is fixed in mesa master as of:

commit cd2e2187cb45accb13bf89ef297324332c46f379
Author: Carl Worth <cworth@cworth.org>
Date:   Thu Feb 2 11:29:51 2012 -0800

    glsl: Avoid ralloc_stealing a long-lived object to a short-lived parent


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.