Bug 82920 - Invalid read during geometry program build
Summary: Invalid read during geometry program build
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: glsl-compiler (show other bugs)
Version: git
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Ian Romanick
QA Contact: Intel 3D Bugs Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-21 20:11 UTC by pavol
Modified: 2016-02-16 19:03 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
mc (17.21 KB, text/plain)
2014-08-21 20:11 UTC, pavol
Details
fixed mc (17.19 KB, application/x-gzip)
2014-08-22 11:14 UTC, pavol
Details
fix for valgrind warnings (1.87 KB, patch)
2014-10-13 08:11 UTC, Tapani Pälli
Details | Splinter Review
MC with filtering (69.52 KB, text/plain)
2015-01-19 14:59 UTC, pavol
Details
MC with filtering zip (69.52 KB, application/zip)
2015-01-19 15:00 UTC, pavol
Details

Description pavol 2014-08-21 20:11:48 UTC
Created attachment 105060 [details]
mc

When I try to compile marching cubes geometry program I get a lot of these

==31997== Invalid read of size 8
==31997==    at 0x9B51ED0: ??? (in /usr/lib/x86_64-linux-gnu/dri/r600_dri.so)
==31997==    by 0x9B49F4F: ??? (in /usr/lib/x86_64-linux-gnu/dri/r600_dri.so)
==31997==    by 0x9B93E56: ??? (in /usr/lib/x86_64-linux-gnu/dri/r600_dri.so)
==31997==    by 0x9A7CB2E: ??? (in /usr/lib/x86_64-linux-gnu/dri/r600_dri.so)
==31997==    by 0x9A7ED00: ??? (in /usr/lib/x86_64-linux-gnu/dri/r600_dri.so)
==31997==    by 0x405371: main (mc.c:155)


and these

EE ../../../../../../src/gallium/drivers/r600/r600_shader.c:353 tgsi_is_supported - unsupported src 0 (dimension 1)
EE ../../../../../../src/gallium/drivers/r600/r600_shader.c:157 r600_pipe_shader_create - translation from TGSI failed !
EE ../../../../../../src/gallium/drivers/r600/r600_state_common.c:751 r600_shader_select - Failed to build shader variant (type=2) -22


I have attached whole program. It needs GLFW3 and GLEW.
Comment 1 pavol 2014-08-22 11:14:59 UTC
Created attachment 105095 [details]
fixed mc
Comment 2 pavol 2014-08-22 11:15:14 UTC
I have tested new version on nvidia driver and test it on mesa when I get home. In original version there was a bug where UBOs were not binded (I am not sure if KHR_debug should report this).
Comment 3 pavol 2014-08-22 19:13:18 UTC
I tested modified version and it still crashes
Comment 4 Glenn Kennard 2014-10-12 12:24:42 UTC
Testing "fixed_mc" with a debug-enabled mesa build I get:

Mesa: User error: GL_INVALID_ENUM in glGetString(GL_EXTENSIONS)
- this is from GLFW as far as i can tell, its trying to get the extension string using the old method which is not supported in a >= 3.3 core context. Otherwise unrelated to this bug though.

valgrind:
==30990== Invalid read of size 8
==30990==    at 0x9F90847: ast_interface_block::hir(exec_list*, _mesa_glsl_parse_state*) (ast_to_hir.cpp:5688)
==30990==    by 0x9F875FC: _mesa_ast_to_hir(exec_list*, _mesa_glsl_parse_state*) (ast_to_hir.cpp:100)
==30990==    by 0x9FDB07A: _mesa_glsl_compile_shader (glsl_parser_extras.cpp:1462)
==30990==    by 0x9EB843D: compile_shader (shaderapi.c:849)
==30990==    by 0x9EBA1AD: _mesa_create_shader_program (shaderapi.c:1830)
==30990==    by 0x9EBA7C7: _mesa_CreateShaderProgramv (shaderapi.c:1919)
==30990==    by 0x6C29EED: shared_dispatch_stub_892 (glapi_mapi_tmp.h:20555)
==30990==    by 0x404B0D: main (in /recording/download/20140803/mc/mc)

and a number of further errors in that function, then later the gallium state tracker throws an assertion:
../../src/mesa/state_tracker/st_glsl_to_tgsi.cpp:2104:visit: Assertion `var->data.location != -1' failed.

In release mode this check drops through and the r600 tgsi translator rejects it with:
EE ../../../../../../src/gallium/drivers/r600/r600_shader.c:353 tgsi_is_supported - unsupported src 0 (dimension 1)
and replaces the shader with a no-op dummy shader to not crash.


Basically the gallium driver layer is getting bad data out from the GLSL compiler.
Comment 5 Tapani Pälli 2014-10-13 06:52:09 UTC
How do you compile the example? With "gcc mc.c `pkg-config --cflags --libs glfw3` -std=c99 -lGL -lGLEW" I'm still getting:
mc.c:(.text+0x702): undefined reference to `glBufferStorage'
Comment 6 Tapani Pälli 2014-10-13 07:16:53 UTC
(In reply to Tapani Pälli from comment #5)
> How do you compile the example? With "gcc mc.c `pkg-config --cflags --libs
> glfw3` -std=c99 -lGL -lGLEW" I'm still getting:
> mc.c:(.text+0x702): undefined reference to `glBufferStorage'

forget it, I got it building eventually, intel driver crashes when running this when compiling the geometry shader ...
Comment 7 Tapani Pälli 2014-10-13 08:11:34 UTC
Created attachment 107763 [details] [review]
fix for valgrind warnings

This fix removes invalid access to the deleted resource making valgrind happy, it does not fix this bug though.
Comment 8 pavol 2014-10-13 10:10:25 UTC
(In reply to Tapani Pälli from comment #7)
> Created attachment 107763 [details] [review] [review]
> fix for valgrind warnings
> 
> This fix removes invalid access to the deleted resource making valgrind
> happy, it does not fix this bug though.

you can simplify one if statement, here is a proof:

((!earlier && !is_gl_identifier(var->name)) || earlier == NULL)

(!A && !B) || !(A != NULL)
(!A && !B) || !A
(!A || !A) && (!A || !B)
true && (!A || !B)
!A || !B

hence
(!earlier || !is_gl_identifier(var->name))
Comment 9 pavol 2014-10-13 10:13:18 UTC
Scratch that; I ashamed.
Comment 10 Ian Romanick 2014-12-17 20:06:26 UTC
Was this also fixed by the fix for bug #82585?

commit a909b995d95892798a189818454905fdefd4bc9b
Author: Ian Romanick <ian.d.romanick@intel.com>
Date:   Mon Dec 1 14:07:30 2014 -0800

    linker: Assign varying locations geometry shader inputs for SSO
    
    Previously only geometry shader outputs would be assigned locations if
    the geometry shader was the only stage in the linked program.
    
    Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
    Cc: pavol@klacansky.com
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82585
    Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Comment 11 pavol 2014-12-17 21:10:15 UTC
No, it just shows black screen.
Comment 12 pavol 2015-01-19 14:59:04 UTC
Created attachment 112476 [details]
MC with filtering
Comment 13 pavol 2015-01-19 15:00:35 UTC
Created attachment 112477 [details]
MC with filtering zip
Comment 14 pavol 2015-01-19 15:02:19 UTC
I have added nearest filtering to the 3D texture (not sure if immutable levels are handled correctly in the driver) and it works on Mac and locks gpu on linux.

Can you please test it so we can close this? I will have to report separate bug for lockup.
Comment 15 Timothy Arceri 2016-02-16 12:07:15 UTC
The latest example program runs on i965. If there as still issue with r600 I suggest you file a fresh bug.
Comment 16 pavol 2016-02-16 19:03:31 UTC
Yes, even software rendering works.

https://bugs.freedesktop.org/show_bug.cgi?id=94179


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.