Repository navigation
Description
This was prompted again by various recent discussions:
- out of bounds accesses here
- corner cases in signed integer division, here
- array indexing overflow, here
- discussion during the 2021-06-15 meeting
Right now, the spec defines:
- program error: "a failure to satisfy the requirements of the specification"
- and its sub-category: dynamic error as is any program occurring during shader execution.
Portability desires push us to make the spec specify outcomes in more situations, i.e. minimize the bad cases.
There are common patterns of "bad cases":
- Sometimes a computation produces an "unspecified value", i.e. some value (of the target type) but not pinned down by the spec.
- In some languages, each observation of that produced value can materialize as a different value of the target type. (Hilarity ensues.)
- Sometimes the result is "Undefined behavior". The spec no longer applies in this case and therefore provides no guidance on the behaviour of the program, either before or after the occurrence of the triggering behaviour. The program literally has no specified meaning.
* Example: In C, integer division by zero yields undefined behaviour. (MSL softens this case to undef value.)
Sometimes an undef value triggers undefined behaviour later on. For example, it is undefined behaviour to branch on an undef value.
Things to be decided:
- reconciling bad cases in underlying platforms vs. WGSL
- Can we reasonably polyfill make WGSL more specified than what comes out of the box from the underlying platform's undefined behaviour, or undef values.
- Do we need to make new subcategories of "dynamic error".
I'm obliged to point to Taming undefined behavior in LLVM (which I consider a classic). Further work proposes replacing "undef" with a combination of a "freeze" primitive and "poison" value. E.g. RFC and presentation. Note that LLVM still has undef and freeze and poison values. (For the hardware-inclined, undef is analogous to a metastable or unsettled value, and 'freeze' is analogous to a chain of synchronization registers with a given MTBF.)
Activity
dneto0 commentedon Feb 8, 2022
Led to partitioning of error cases:
Closing