aboutsummaryrefslogtreecommitdiffstats
path: root/src/panfrost/midgard
diff options
context:
space:
mode:
authorTomeu Vizoso <[email protected]>2019-12-12 14:37:46 +0100
committerTomeu Vizoso <[email protected]>2019-12-12 16:26:40 +0100
commit47a73888f58e305a2f8e6da5d1c6a836191f82df (patch)
treef0df9f693383802bb40ace80dbc292efc74c8280 /src/panfrost/midgard
parent5dfe41239c321ff1b6af6ce261caefe99be6b675 (diff)
pan/midgard: Remove undefined behavior
As found by UBSAN, it should be harmless but it's good to remove any UB so the tool's output is useful. ../src/panfrost/midgard/midgard_schedule.c:1094:9: runtime error: index -1 out of bounds for type 'midgard_instruction *[6]'"} #0 0xad047872 in schedule_block ../src/panfrost/midgard/midgard_schedule.c:1094"} #1 0xad04d41a in schedule_program ../src/panfrost/midgard/midgard_schedule.c:1116"} #2 0xad031f98 in midgard_compile_shader_nir ../src/panfrost/midgard/midgard_compile.c:2588"} #3 0xacf9874e in panfrost_shader_compile ../src/gallium/drivers/panfrost/pan_assemble.c:68"} #4 0xacf6b268 in panfrost_bind_shader_state ../src/gallium/drivers/panfrost/pan_context.c:1960"} #5 0xaae2596e in st_update_fp ../src/mesa/state_tracker/st_atom_shader.c:168"} #6 0xaae12316 in st_validate_state ../src/mesa/state_tracker/st_atom.c:261"} #7 0xaadc58c2 in prepare_draw ../src/mesa/state_tracker/st_draw.c:132"} #8 0xaadc58c2 in st_draw_vbo ../src/mesa/state_tracker/st_draw.c:184"} #9 0xabc4f924 in _mesa_validated_drawrangeelements ../src/mesa/main/draw.c:816"} #10 0xabc50240 in _mesa_DrawElements ../src/mesa/main/draw.c:970"} #11 0x73ebd2 in glu::CallLogWrapper::glDrawElements(unsigned int, int, unsigned int, void const*) (/deqp/modules/gles2/deqp-gles2+0x2d4bd2)"} #12 0x6d86b2 in deqp::gls::FragOpInteractionCase::iterate() (/deqp/modules/gles2/deqp-gles2+0x26e6b2)"} #13 0x494d16 in deqp::gles2::TestCaseWrapper::iterate(tcu::TestCase*) (/deqp/modules/gles2/deqp-gles2+0x2ad16)"} #14 0x7f9cf2 in tcu::TestSessionExecutor::iterateTestCase(tcu::TestCase*) (/deqp/modules/gles2/deqp-gles2+0x38fcf2)"} #15 0x7fa5f0 in tcu::TestSessionExecutor::iterate() (/deqp/modules/gles2/deqp-gles2+0x3905f0)"} #16 0x7e1aac in tcu::App::iterate() (/deqp/modules/gles2/deqp-gles2+0x377aac)"} #17 0x492d4c in main (/deqp/modules/gles2/deqp-gles2+0x28d4c)"} #18 0xb64b9aa8 in __libc_start_main (/lib/arm-linux-gnueabihf/libc.so.6+0x1aaa8)"} Signed-off-by: Tomeu Vizoso <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/panfrost/midgard')
-rw-r--r--src/panfrost/midgard/compiler.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h
index f2fc5d36146..518de4c7df4 100644
--- a/src/panfrost/midgard/compiler.h
+++ b/src/panfrost/midgard/compiler.h
@@ -390,7 +390,7 @@ mir_next_op(struct midgard_instruction *ins)
mir_foreach_bundle_in_block_rev(block, _bundle) \
for (i = (_bundle->instruction_count - 1), v = _bundle->instructions[i]; \
i >= 0; \
- --i, v = _bundle->instructions[i]) \
+ --i, v = (i >= 0) ? _bundle->instructions[i] : NULL) \
#define mir_foreach_instr_global(ctx, v) \
mir_foreach_block(ctx, v_block) \