Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix uses of uninitialized data #46965

Merged
merged 3 commits into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/coreclr/jit/codegenarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,10 @@ void CodeGen::genCodeForTreeNode(GenTree* treeNode)
case GT_PINVOKE_PROLOG:
noway_assert(((gcInfo.gcRegGCrefSetCur | gcInfo.gcRegByrefSetCur) & ~fullIntArgRegMask()) == 0);

#ifdef PSEUDORANDOM_NOP_INSERTION
// the runtime side requires the codegen here to be consistent
emit->emitDisableRandomNops();
#endif // PSEUDORANDOM_NOP_INSERTION
break;

case GT_LABEL:
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/jit/codegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1793,8 +1793,10 @@ void CodeGen::genCodeForTreeNode(GenTree* treeNode)
case GT_PINVOKE_PROLOG:
noway_assert(((gcInfo.gcRegGCrefSetCur | gcInfo.gcRegByrefSetCur) & ~fullIntArgRegMask()) == 0);

#ifdef PSEUDORANDOM_NOP_INSERTION
// the runtime side requires the codegen here to be consistent
emit->emitDisableRandomNops();
#endif // PSEUDORANDOM_NOP_INSERTION
break;

case GT_LABEL:
Expand Down
7 changes: 6 additions & 1 deletion src/coreclr/jit/emit.h
Original file line number Diff line number Diff line change
Expand Up @@ -1846,10 +1846,13 @@ class emitter

unsigned emitNxtIGnum;

#ifdef PSEUDORANDOM_NOP_INSERTION

// random nop insertion to break up nop sleds
unsigned emitNextNop;
bool emitRandomNops;
void emitEnableRandomNops()

void emitEnableRandomNops()
{
emitRandomNops = true;
}
Expand All @@ -1858,6 +1861,8 @@ class emitter
emitRandomNops = false;
}

#endif // PSEUDORANDOM_NOP_INSERTION

insGroup* emitAllocAndLinkIG();
insGroup* emitAllocIG();
void emitInitIG(insGroup* ig);
Expand Down
21 changes: 11 additions & 10 deletions src/coreclr/jit/flowgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9186,18 +9186,19 @@ class MergedReturns
// Need to check both for matching const val and for genReturnBB
// because genReturnBB is used for non-constant returns and its
// corresponding entry in the returnConstants array is garbage.
if (returnConstants[i] == constVal)
{
BasicBlock* returnBlock = returnBlocks[i];
// Check the returnBlocks[] first, so we don't access an uninitialized
// returnConstants[] value (which some tools like valgrind will
// complain about).

if (returnBlock == comp->genReturnBB)
{
// This is the block used for non-constant returns, so
// its returnConstants entry is just garbage; don't be
// fooled.
continue;
}
BasicBlock* returnBlock = returnBlocks[i];

if (returnBlock == comp->genReturnBB)
{
continue;
}

if (returnConstants[i] == constVal)
{
*index = i;
return returnBlock;
}
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/jit/instr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ void CodeGen::instGen(instruction ins)
GetEmitter()->emitIns(ins);

#ifdef TARGET_XARCH
#ifdef PSEUDORANDOM_NOP_INSERTION
// A workaround necessitated by limitations of emitter
// if we are scheduled to insert a nop here, we have to delay it
// hopefully we have not missed any other prefix instructions or places
Expand All @@ -201,6 +202,7 @@ void CodeGen::instGen(instruction ins)
{
GetEmitter()->emitNextNop = 1;
}
#endif // PSEUDORANDOM_NOP_INSERTION
#endif
}

Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/jit/lsra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -716,9 +716,10 @@ LinearScan::LinearScan(Compiler* theCompiler)
, refPositions(theCompiler->getAllocator(CMK_LSRA_RefPosition))
, listNodePool(theCompiler)
{
firstColdLoc = MaxLocation;

#ifdef DEBUG
maxNodeLocation = 0;
firstColdLoc = MaxLocation;
activeRefPosition = nullptr;

// Get the value of the environment variable that controls stress for register allocation
Expand Down