Skip to content

Commit c9780ae

Browse files
cursoragenttimfox
andcommitted
Fix Vulkan PBR pipeline stack smash (fragment spec map entries)
ADD_FRAG_SPEC appended 41 VkSpecializationMapEntry values but spec_entries was only 38 slots with USE_VK_PBR, corrupting the stack canary and aborting after VarInfo during vk_create_pipelines. Enlarge to 48 with headroom and add a fatal overflow guard. Co-authored-by: Tim Fox <timfox@outlook.com>
1 parent 3d2a64a commit c9780ae

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

docs/TODO_TRIAGE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ TODOs/FIXMEs in `src/external/` are from third-party code (duktape, zstd, cjson,
6868

6969
| Date | Scope | Notes |
7070
|------|--------|------|
71+
| 2026-04-27 | Vulkan / PBR | `vk_create_pipeline.c`: PBR `ADD_FRAG_SPEC` wrote 41 map entries into `spec_entries[38]` (stack smash / SIGABRT after `VarInfo`); enlarged buffer + overflow guard. |
7172
| 2026-04-27 | Vulkan / IQM | `tr_model_iqm.c`: avoid `-Wcast-qual` on `backEnd.currentEntity` (uintptr_t bridge). Vegetation wind: `vk_vegetation_wind.c` header + triage row clarify dispatch-after-draw vs binding `vegwind_vertex_buffer` (still TODO). |
7273
| 2026-04-11 | Network / downloads | `cl_curl.c`: `dl->Name` from `Content-Disposition` uses **`Q_strncpyz`** (Phase 2 P0 item remains fixed). |
7374
| 2026-04-11 | Botlib / preprocessor | **`src/botlib/l_precomp.c`** already bounded; duplicate **`src/platform/botlib/l_precomp.c`** and **`src/platform/win32/botlib/l_precomp.c`** aligned: `sprintf`**`Com_sprintf(..., MAX_TOKEN, ...)`** (5 sites each). |

src/renderers/vulkan/vk_create_pipeline.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ VkPipeline vk_create_pipeline( const Vk_Pipeline_Def *def, renderPass_t renderPa
6666
struct Vk_Pipeline_FragSpecData frag_spec_data;
6767

6868
#ifdef USE_VK_PBR
69-
VkSpecializationMapEntry spec_entries[38];
69+
/* ADD_FRAG_SPEC: 11 base + 30 PBR (constant_id 11..40) + lightmap_scale/srgb = 41 entries; was 38 (stack smash / SIGABRT). */
70+
VkSpecializationMapEntry spec_entries[48];
7071
#else
71-
VkSpecializationMapEntry spec_entries[12];
72+
VkSpecializationMapEntry spec_entries[12];
7273
#endif
7374

7475
VkSpecializationInfo frag_spec_info;
@@ -817,6 +818,11 @@ VkPipeline vk_create_pipeline( const Vk_Pipeline_Def *def, renderPass_t renderPa
817818

818819
frag_spec_data.lightmap_srgb_decode = ( r_lightmap_srgb_decode && r_lightmap_srgb_decode->integer && r_hdr && r_hdr->integer > 0 ) ? 1 : 0;
819820

821+
if ( spec_entry_count > (int)( sizeof( spec_entries ) / sizeof( spec_entries[0] ) ) ) {
822+
ri.Error( ERR_FATAL, "vk_create_pipeline: fragment specialization map overflow (%d > %u)",
823+
spec_entry_count, (unsigned int)( sizeof( spec_entries ) / sizeof( spec_entries[0] ) ) );
824+
}
825+
820826
frag_spec_info.mapEntryCount = spec_entry_count;
821827
frag_spec_info.pMapEntries = spec_entries;
822828
frag_spec_info.dataSize = sizeof( frag_spec_data );

0 commit comments

Comments
 (0)