Skip to content

groupshared-uninitialized-read

Status: stub. The full-length analysis is queued for a v1.0.x patch release per ADR 0018, section 5, criterion #6. The companion rule page at docs/rules/groupshared-uninitialized-read.md contains the canonical detection logic + GPU reasoning.

TL;DR

Groupshared memory (LDS on AMD, shared memory on NVIDIA, SLM on Intel Xe) is allocated per thread group and retains its value only for the duration of a single group's lifetime. At the start of a group's execution, the contents of its LDS allocation are undefined — the hardware does not zero-initialise it. On most implementations, LDS will contain whatever a previous thread group wrote to those addresses before it finished, or potentially hardware-specific reset values. Either way, reading before writing produces a value that is not under programmer control and will vary across hardware, driver versions, and group scheduling order.

What the rule fires on

Reads from a groupshared variable or array element before any thread in the group has executed a write to that location in the current dispatch, and where no GroupMemoryBarrierWithGroupSync between a covering write and the read has been established. The rule fires when the first use of a groupshared symbol in the shader body (within a [numthreads]-annotated function) is a load expression rather than a store, and when no unconditional write precedes the read either in the same thread's code path or guarded by a barrier that covers all threads. It does not fire when the read is preceded by an unconditional write to the same location by the same thread, or when the pattern matches the established initialise-barrier-read idiom (all threads write, barrier, all threads read).

See the What it detects section of the rule page for the full pattern definition.

Why it matters

The full GPU-mechanism analysis lives in the Why it matters on a GPU section of the companion rule page.

Examples

The bad / good code snippets are kept canonical on the rule page; see groupshared-uninitialized-read.md -> Examples.

See also


This is a v1.0-ship stub. Full analysis pending; track issue link TBD.

© 2026 NelCit — Apache-2.0 (code), CC-BY-4.0 (docs).