Bug 64087 - Webgl conformance shader-with-non-reserved-words crash when mesa is compiled without --enable-debug
Summary: Webgl conformance shader-with-non-reserved-words crash when mesa is compiled ...
Alias: None
Product: Mesa
Classification: Unclassified
Component: glsl-compiler (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Kenneth Graunke
QA Contact:
URL: http://www.khronos.org/registry/webgl...
Depends on:
Blocks: 67224
  Show dependency treegraph
Reported: 2013-04-30 13:02 UTC by Pavel Ondračka
Modified: 2013-07-27 17:37 UTC (History)
4 users (show)

See Also:
i915 platform:
i915 features:


Description Pavel Ondračka 2013-04-30 13:02:36 UTC
Just grab a latest firefox, probably any driver (tested with r300g and llvmpipe), release build of mesa (without --enable-debug) and go to http://https://www.khronos.org/registry/webgl/sdk/tests/conformance/glsl/misc/shader-with-non-reserved-words.html 

With --enable-debug the test still fails but doesn't crash.  

Program received signal SIGSEGV, Segmentation fault.
0x926c44fa in hash_table_string_hash (key=0x27f0e7f)
    at ../../../src/mesa/program/prog_hash_table.c:215
215	    while (*str != '\0') {
(gdb) bt
#0  0x926c44fa in hash_table_string_hash (key=0x27f0e7f)
    at ../../../src/mesa/program/prog_hash_table.c:215
#1  0x926c414f in get_node (ht=ht@entry=0x988bf670, key=key@entry=0x27f0e7f)
    at ../../../src/mesa/program/prog_hash_table.c:114
#2  0x926c42d0 in hash_table_find (ht=0x988bf670, key=key@entry=0x27f0e7f)
    at ../../../src/mesa/program/prog_hash_table.c:132
#3  0x926d72fc in find_symbol (table=0x986e0eb0, name=
    0x27f0e7f <Address 0x27f0e7f out of bounds>)
    at ../../../src/mesa/program/symbol_table.c:200
#4  _mesa_symbol_table_add_symbol (table=0x986e0eb0, name_space=-1, name=
    0x27f0e7f <Address 0x27f0e7f out of bounds>, declaration=0xa16784d8)
    at ../../../src/mesa/program/symbol_table.c:335
#5  0x9267ae4a in glsl_symbol_table::add_type (this=0xa1673778, name=
    0x27f0e7f <Address 0x27f0e7f out of bounds>, t=0x93620648 <glsl_type::_void_type>)
    at ../../../src/glsl/glsl_symbol_table.cpp:118
#6  0x92676311 in _mesa_glsl_parse (state=0x98881318) at glsl_parser.yy:1498
#7  0x926b9390 in _mesa_glsl_compile_shader (ctx=ctx@entry=0x90061000, shader=shader@entry=
    0x986f8d58) at ../../../src/mesa/program/ir_to_mesa.cpp:3110
#8  0x925a8563 in compile_shader (ctx=0x90061000, shaderObj=<optimized out>)
    at ../../src/mesa/main/shaderapi.c:749
#9  0xb6310f43 in fCompileShader (this=<optimized out>, shader=3168)
    at ../../../dist/include/GLContext.h:2559
#10 mozilla::WebGLContext::CompileShader (this=0x98880e20, shader=0x986e2970)
    at /usr/src/debug/xulrunner-20.0/mozilla-release/content/canvas/src/WebGLContextGL.cpp:4322
#11 0xb6c14e44 in mozilla::dom::WebGLRenderingContextBinding::compileShader (cx=0x988fd880, 
    obj=..., self=0x98880e20, argc=1, vp=0xb19ff200)
    at /usr/src/debug/xulrunner-20.0/mozilla-release/objdir/dom/bindings/WebGLRenderingContextBinding.cpp:4504
---Type <return> to continue, or q <return> to quit---
#12 0xb6c1431c in mozilla::dom::WebGLRenderingContextBinding::genericMethod (cx=0x988fd880, 
    argc=1, vp=0xb19ff200)
    at /usr/src/debug/xulrunner-20.0/mozilla-release/objdir/dom/bindings/WebGLRenderingContextBinding.cpp:10168
#13 0xa742599a in ?? ()
#14 0x4b2d7000 in ?? () from /usr/lib/xulrunner/libmozjs.so
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

Mesa: f1361ed084c3805abfab461c638e62cbc9b0fcf5
Comment 1 Ian Romanick 2013-07-23 18:50:51 UTC
I don't know if it's the same error, but I currently get:

*** Error compiling VERTEX_SHADER '[object WebGLShader]':0:5(1): error: syntax error, unexpected IDENTIFIER
FAIL shader with: 'layout' failed to compile
PASS getError was expected value: NO_ERROR : should be no GL errors

for this shader:

struct layout {
    vec4 layout;
struct Foo {
    layout layout;
attribute vec4 position;
void main()
    Foo f;
    f.layout.layout = position;
    gl_Position = f.layout.layout;

There are similar errors for some other things that are reserved words in GLSL versions other than OpenGL ES 2.0.
Comment 2 Tapani Pälli 2013-07-26 06:16:38 UTC
For me only the keywords of ARB_texture_cube_map_array_enable extension seem to cause the issues. I've sent patch to mesa-dev list that fixes this test for me.
Comment 3 Kenneth Graunke 2013-07-26 19:45:58 UTC
Tapani fixed the crash with:

commit 8c211dd742669bc03b44186e41e5aa40081d6bcc
Author: Tapani Pälli <tapani.palli@intel.com>
Date:   Fri Jul 26 10:21:56 2013 +0300

    glsl: disable ARB_texture_cube_map_array_enable keywords for glsl es
    Patch fixes a crash with Webgl 'shader-with-non-reserved-words'
    conformance test by ignoring desktop extension keywords on GLSL ES.
    v2: fix reserved and allowed desktop glsl versions (Chris)
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64087
    Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
    Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
    Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>

The test still failed, however, due to the issue with "layout" Ian pointed out.  That should be fixed with:
Comment 4 Kenneth Graunke 2013-07-27 17:37:44 UTC
The test should now pass as of:

commit c178ec0d7e8cc7007cb34e4f56f14261a057c200
Author: Kenneth Graunke <kenneth@whitecape.org>
Date:   Fri Jul 26 12:31:06 2013 -0700

    glsl: Classify "layout" like other identifiers.
    When "layout" isn't being lexed as LAYOUT_TOK, we should treat it like
    an ordinary identifier.  This means we need to classify it to determine
    whether we should return IDENTIFIER, TYPE_IDENTIFIER, or NEW_IDENTIFIER.
    Fixes the WebGL conformance test "shader-with-non-reserved-words."
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64087
    Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
    Reviewed-by: Matt Turner <mattst88@gmail.com>
    Cc: mesa-stable@lists.freedesktop.org

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.