Skip to content

[Audit][High] GpuMesher.finalizeCompletedMeshes ignores vkWaitForFences return value #747

Description

@MichaelFisher1997

Module Scanned

modules/world-runtime/src/gpu_mesher.zig

Summary

The finalizeCompletedMeshes function calls vkWaitForFences but discards the return value. If the fence wait fails, the code continues to read potentially stale data from the result buffer.

Location

modules/world-runtime/src/gpu_mesher.zig:168

Severity: High

Incorrect rendering, memory corruption, crashes

Impact

When vkWaitForFences returns VK_TIMEOUT or VK_ERROR_DEVICE_LOST, the code proceeds to read results from the buffer. If GPU has not finished writing, data is stale/garbage.

Evidence

Line 168: _ = c.vkWaitForFences(...); // Return value discarded

Lines 185-244: Results read immediately assuming fence wait succeeded

Proposed Fix

Check return value and handle failures: if (wait_result != c.VK_SUCCESS) { log.warn(...); return; }

Acceptance Criteria

  • vkWaitForFences return value is checked
  • On failure, function returns early
  • Submitted items cleared on failure
  • zig build test passes

Metadata

Metadata

Assignees

No one assigned

    Labels

    automated-auditIssues found by automated opencode audit scansbugSomething isn't workinghotfix

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions