Bug 91290 - SIGSEGV glcpp/glcpp-parse.y:1077
Summary: SIGSEGV glcpp/glcpp-parse.y:1077
Alias: None
Product: Mesa
Classification: Unclassified
Component: Mesa core (show other bugs)
Version: 10.3
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: mesa-dev
QA Contact: mesa-dev
Keywords: bisected, have-backtrace, regression
Depends on:
Reported: 2015-07-10 05:17 UTC by Vinson Lee
Modified: 2015-07-24 05:06 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Description Vinson Lee 2015-07-10 05:17:42 UTC
mesa: f12302b89836a24255674a251f7a6902b4e9af7c (master 10.7.0-devel)

This minimum shader triggers a null pointer dereference in the GLSL compiler.

#define A 1 /* comment */
#define A 1 /* comment */

(gdb) bt
#0  _token_list_equal_ignoring_space (b=<optimized out>, a=<optimized out>) at glcpp/glcpp-parse.y:1077
#1  _macro_equal (a=0x20863a0, b=0x2086080) at glcpp/glcpp-parse.y:2112
#2  0x0000000000498117 in _define_object_macro (parser=parser@entry=0x2082110, loc=loc@entry=0x7ffe7e7b0414, identifier=0x2086150 "A", 
    replacements=0x2086240) at glcpp/glcpp-parse.y:2141
#3  0x000000000049b966 in glcpp_parser_parse (parser=parser@entry=0x2082110) at glcpp/glcpp-parse.y:254
#4  0x00000000004637f2 in glcpp_preprocess (ralloc_ctx=0x2081790, shader=0x7ffe7e7b14b0, info_log=0x20819b0, 
    extensions=<optimized out>, gl_ctx=<optimized out>) at glcpp/pp.c:226
#5  0x0000000000428ef4 in _mesa_glsl_compile_shader (ctx=0x7ffe7e7b1540, shader=0x2080b70, dump_ast=<optimized out>, 
    dump_hir=<optimized out>) at glsl_parser_extras.cpp:1504
#6  0x0000000000406345 in compile_shader (ctx=0x7ffe7e7b1540, shader=0x2080b70) at main.cpp:293
#7  0x000000000040437f in main (argc=2, argv=0x7ffe7e7d4528) at main.cpp:392
(gdb) frame 0
#0  _token_list_equal_ignoring_space (b=<optimized out>, a=<optimized out>) at glcpp/glcpp-parse.y:1077
1077				while (node_a->token->type == SPACE)
(gdb) print node_a
$2 = (token_node_t *) 0x0
Comment 1 Vinson Lee 2015-07-10 19:08:47 UTC
a6e9cd14cad555520ad98213adf541a7687a7498 is the first bad commit
commit a6e9cd14cad555520ad98213adf541a7687a7498
Author: Anuj Phogat <anuj.phogat@gmail.com>
Date:   Fri Jun 6 16:56:59 2014 -0700

    glsl/glcpp: Fix preprocessor error condition for macro redefinition
    This patch specifically fixes redefinition condition for white space
    changes. #define and #undef functionality in GLSL follows the standard
    for C++ preprocessors for macro definitions.
    From https://gcc.gnu.org/onlinedocs/cpp/Undefining-and-Redefining-Macros.html:
    These definitions are effectively the same:
         #define FOUR (2 + 2)
         #define FOUR         (2    +    2)
         #define FOUR (2 /* two */ + 2)
    but these are not:
         #define FOUR (2 + 2)
         #define FOUR ( 2+2 )
         #define FOUR (2 * 2)
         #define FOUR(score,and,seven,years,ago) (2 + 2)
    Fixes Khronos GLES3 CTS tests;
    Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
    Reviewed-by: Carl Worth <cworth@cworth.org>

:040000 040000 21e3582eed6555a0e4510982863892e0ead45930 6bb0f8508d19b41b5938b9f812b793ba90c278a0 M	src
bisect run success
Comment 2 Samuel Iglesias Gonsálvez 2015-07-23 09:20:46 UTC
I sent a patch to the mailing list fixing this issue:

Comment 3 Samuel Iglesias Gonsálvez 2015-07-24 05:06:04 UTC
Patch pushed to master.

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.