Commit 9555830f by Nicolas Capens Committed by Nicolas Capens

Fix initializing bits after bitfields

SpirvShader::InterfaceComponent is used as part of the state that comprises the lookup key for cached Reactor routines. It uses 1-bit bitfields for Boolean values, and the bits following it for padding may be left uninitialized by the compiler. Computing the hash of all the state is done by XORing together the memory, so it shouldn't have any- thing uninitialized. While we memset all of SetupProcessor::State to 0, the InterfaceComponent state copied in still contained the uninitialized bits. Computing a hash from it was detected by MemorySanitizer. Bug chromium:967824 Change-Id: If1676831fc838bf2a6ca869d13e6f6d2052fa6d8 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/32128 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarSean Risser <srisser@google.com>
parent 9b627525
...@@ -656,12 +656,21 @@ namespace sw ...@@ -656,12 +656,21 @@ namespace sw
struct InterfaceComponent struct InterfaceComponent
{ {
AttribType Type; AttribType Type;
bool Flat : 1;
bool Centroid : 1; union
bool NoPerspective : 1; {
struct
{
bool Flat : 1;
bool Centroid : 1;
bool NoPerspective : 1;
};
uint8_t DecorationBits;
};
InterfaceComponent() InterfaceComponent()
: Type{ATTRIBTYPE_UNUSED}, Flat{false}, Centroid{false}, NoPerspective{false} : Type{ATTRIBTYPE_UNUSED}, DecorationBits{0}
{ {
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment