KhronosGroup / KhronosGroup/Vulkan-ValidationLayers

Add check for uninitialized variables being used

Open
#9,766 0 comments 0 reactions 1 assignee Claimed by @spencer-lunarg View on GitHub
GPU-AV
Dominant language
C++
Stars
1k
Forks
504
Avg merge
11h 35m
Merged PRs (30d)
224

Description

We hit in issue in [GPU-AV](https://github.com/KhronosGroup/Vulkan-ValidationLayers/pull/9471#discussion_r2004733025) where we basically had something like https://godbolt.org/z/McxnoT4no

and found that trying to index into an array with an uninitialized `Private OpVariable` causes a driver to crash, but when doing a `if (cache == 0)` or `printf("%u", cache)` on it, it would then be zero

Part of this is a problem that glslang doesn't allow going

```
%uint_0 = OpConstant %uint 0
%_ptr_Private_uint = OpTypePointer Private %uint
%cache = OpVariable %_ptr_Private_uint Private %uint_0
```

but this is something that could easily trip up a real developer. Would be nice to add a [proper VUID](https://gitlab.khronos.org/vulkan/vulkan/-/issues/4222) and check for this in GPU-AV in the future

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.