From f3ba7a84f4518f99800e325b90f251c5bb8ca245 Mon Sep 17 00:00:00 2001 From: Francisco Casas Date: Thu, 10 Apr 2025 15:37:31 -0400 Subject: [PATCH] vkd3d-shader/hlsl: Avoid leaking blocks on YYABORT. Currently program errors might result on instructions that use ctx->error_instr as src. In case we hit YYABORT while parsing another part of the HLSL source, we have to make sure that the block that contains the instruction is properly cleaned up, or we might hit the vkd3d:590273:err:hlsl_free_instr Failed assertion: list_empty(&node->uses) assertion when hlsl_ctx_cleanup() is called after the YYABORT. Consider the following shader: float4 main() : sv_target { // Statement A int p = foo; // initializer argument is ERROR. // Statement B undeclared_fun(); // triggers YYABORT. } Statement A will src the ctx->error_instr because of the undeclared identifier and Statement B will trigger an YYABORT because of the undeclared function. --- libs/vkd3d-shader/hlsl.y | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index bbfe99a3d..f38af1b26 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -6768,6 +6768,7 @@ static void validate_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim, %type statement_list %type switch_statement %type unary_expr +%destructor { destroy_block($$); } %type boolean