Bug 33507 - [glsl] GLSL preprocessor modulus by zero crash
Summary: [glsl] GLSL preprocessor modulus by zero crash
Status: CLOSED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: glsl-compiler (show other bugs)
Version: git
Hardware: All All
: medium critical
Assignee: Chad Versace
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-25 18:57 UTC by Vinson Lee
Modified: 2011-03-26 16:50 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Vinson Lee 2011-01-25 18:57:07 UTC
mesa: 903185bf3b7c3f7723d4a862286839f422665486 (master)

A modulus by zero in the GLSL preprocessor generates a floating point exception.

#if 1 % 0
#endif


(gdb) bt
#0  0x009f2383 in __udivmoddi4 (n=<value optimized out>, d=0, rp=0xbfaecd48) at ../sysdeps/wordsize-32/divdi3.c:94
#1  0x009f254b in __moddi3 (u=1, v=0) at ../sysdeps/wordsize-32/divdi3.c:312
#2  0x007f0406 in yyparse (parser=0x9a54178) at glcpp/glcpp-parse.y:395
#3  0x007f2589 in glcpp_parser_parse (parser=0x9a54178) at glcpp/glcpp-parse.y:1138
#4  0x006fb8cf in preprocess (talloc_ctx=0x9a53e40, shader=0xbfaee778, info_log=0x9a53eac, extensions=0x99df2a4, api=0) at glcpp/pp.c:154
#5  0x006fa110 in _mesa_glsl_compile_shader (ctx=0x99de628, shader=0x9a53d88) at program/ir_to_mesa.cpp:3097
#6  0x0069be28 in compile_shader (ctx=0x99de628, shaderObj=1) at main/shaderapi.c:856
#7  0x0069c77b in _mesa_CompileShaderARB (shaderObj=1) at main/shaderapi.c:1187
(gdb) frame 2
#2  0x007f0406 in yyparse (parser=0x9a54178) at glcpp/glcpp-parse.y:395
395			$$ = $1 % $3;
(gdb) l
390		}
391	|	expression '+' expression {
392			$$ = $1 + $3;
393		}
394	|	expression '%' expression {
395			$$ = $1 % $3;
396		}
397	|	expression '/' expression {
398			if ($3 == 0) {
399				yyerror (& @1, parser,
Comment 1 Chad Versace 2011-02-02 10:22:17 UTC
Fixed by commit:
commit fd1252ab67abb1ea351195e192429f292667a8a2
glcpp: Raise error when modulus is zero
Comment 2 Vinson Lee 2011-03-26 16:50:32 UTC
mesa: 56ef62d9885f805bbfb2243dc860ff425d5b4d3b (master)

Verified fixed.


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.