From 246140fa1c9f8146602dc9fe5ba589604de9ee69 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Fri, 30 Nov 2018 15:23:03 +0100 Subject: [PATCH] vrend: Check whether a shader type actually exisits before uploading constants When changing the from a one-by-one upload to an array upload the test for the array pointer to the uniform IDs was replaced by testing the uniform array ID against -1. However, this is not enough, because when the context is allocated all is cleared to zero, and apparently the structure is re-used in different invocations of shader programs. Here, one shader might have been removed but the const field was still allocated resulting in a sigsegv. This happens e.g. by running dEQP-GLES31.functional.primitive_bounding_box.wide_points. global_state.vertex_tessellation_geometry_fragment.fbo_bbox_larger global_state.vertex_tessellation_geometry_fragment.fbo_bbox_smaller tessellation_set_per_draw.vertex_tessellation_fragment.default_framebuffer_bbox_equal tessellation_set_per_draw.vertex_tessellation_fragment.default_framebuffer_bbox_larger resulting in AddressSanitizer: SEGV on unknown address 0x00000000001c The signal is caused by a READ memory access. Hint: address points to the zero page. #0 0x7f595b9eb875 in vrend_draw_bind_const_shader src/vrend_renderer.c:3677 #1 0x7f595b9ed37f in vrend_draw_bind_objects src/vrend_renderer.c:3810 Work around this by checking whether the shader type data is allocated. Fixes: 172c9679b47c608f561f174c8297465e806c3e00 vrend/shader: handle uniforms as array Tested-by: Jakob Bornecrantz Acked-by: Jakob Bornecrantz Reviewed-by: Gurchetan Singh Signed-off-by: Jakob Bornecrantz --- src/vrend_renderer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index c3ada53..108d281 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -3672,6 +3672,7 @@ static void vrend_draw_bind_const_shader(struct vrend_context *ctx, int shader_type, bool new_program) { if (ctx->sub->consts[shader_type].consts && + ctx->sub->shaders[shader_type] && (ctx->sub->prog->const_location[shader_type] != -1) && (ctx->sub->const_dirty[shader_type] || new_program)) { glUniform4uiv(ctx->sub->prog->const_location[shader_type],