summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Andreenko <seandree@microsoft.com>2019-03-07 19:43:37 -0800
committerGitHub <noreply@github.com>2019-03-07 19:43:37 -0800
commit24d05f5e6cb905da8d2bf84d0b1525586152c908 (patch)
tree7ee721daa2775e7bae876bd86b0cf0b469cb3319
parent4685a1e008ad7cf4118e8778d89e63d87ca5b7b6 (diff)
downloadcoreclr-24d05f5e6cb905da8d2bf84d0b1525586152c908.tar.gz
coreclr-24d05f5e6cb905da8d2bf84d0b1525586152c908.tar.bz2
coreclr-24d05f5e6cb905da8d2bf84d0b1525586152c908.zip
Fix a rare JitStress assert. (#23116)
* Fix undefined behaviour when we check `this==nullptr`. * Fix ifdef comment. * Fix rare jit stress assert. flowgraph.cpp: !IsUninitialized(tree) can fail if `UninitializedWord` returns a valid pointer value.
-rw-r--r--src/jit/compiler.cpp12
-rw-r--r--src/jit/compiler.h4
-rw-r--r--src/jit/ee_il_dll.cpp2
-rw-r--r--src/jit/jit.h2
4 files changed, 13 insertions, 7 deletions
diff --git a/src/jit/compiler.cpp b/src/jit/compiler.cpp
index cef3083c47..489218800e 100644
--- a/src/jit/compiler.cpp
+++ b/src/jit/compiler.cpp
@@ -2135,14 +2135,15 @@ void Compiler::compDoComponentUnitTestsOnce()
// Note that we can't use small values like zero, because we have some
// asserts that can fire for such values.
//
-unsigned char Compiler::compGetJitDefaultFill()
+// static
+unsigned char Compiler::compGetJitDefaultFill(Compiler* comp)
{
unsigned char defaultFill = (unsigned char)JitConfig.JitDefaultFill();
- if ((this != nullptr) && (compStressCompile(STRESS_GENERIC_VARN, 50)))
+ if (comp != nullptr && comp->compStressCompile(STRESS_GENERIC_VARN, 50))
{
unsigned temp;
- temp = info.compMethodHash();
+ temp = comp->info.compMethodHash();
temp = (temp >> 16) ^ temp;
temp = (temp >> 8) ^ temp;
temp = temp & 0xff;
@@ -2153,6 +2154,11 @@ unsigned char Compiler::compGetJitDefaultFill()
{
temp |= 0x80;
}
+
+ // Make a misaligned pointer value to reduce probability of getting a valid value and firing
+ // assert(!IsUninitialized(pointer)).
+ temp |= 0x1;
+
defaultFill = (unsigned char)temp;
}
diff --git a/src/jit/compiler.h b/src/jit/compiler.h
index e39c44fed9..e390fd5e43 100644
--- a/src/jit/compiler.h
+++ b/src/jit/compiler.h
@@ -8851,8 +8851,8 @@ public:
bool compDonotInline();
#ifdef DEBUG
- unsigned char compGetJitDefaultFill(); // Get the default fill char value
- // we randomize this value when JitStress is enabled
+ // Get the default fill char value we randomize this value when JitStress is enabled.
+ static unsigned char compGetJitDefaultFill(Compiler* comp);
const char* compLocalVarName(unsigned varNum, unsigned offs);
VarName compVarName(regNumber reg, bool isFloatReg = false);
diff --git a/src/jit/ee_il_dll.cpp b/src/jit/ee_il_dll.cpp
index 8b2f29e7d8..410ef6ca01 100644
--- a/src/jit/ee_il_dll.cpp
+++ b/src/jit/ee_il_dll.cpp
@@ -270,7 +270,7 @@ void JitTls::SetCompiler(Compiler* compiler)
reinterpret_cast<JitTls*>(GetJitTls())->m_compiler = compiler;
}
-#else // defined(DEBUG)
+#else // !defined(DEBUG)
JitTls::JitTls(ICorJitInfo* jitInfo)
{
diff --git a/src/jit/jit.h b/src/jit/jit.h
index 5cdb1fdcb9..5157d66e98 100644
--- a/src/jit/jit.h
+++ b/src/jit/jit.h
@@ -867,7 +867,7 @@ inline T UninitializedWord(Compiler* comp)
{
comp = JitTls::GetCompiler();
}
- defaultFill = comp->compGetJitDefaultFill();
+ defaultFill = Compiler::compGetJitDefaultFill(comp);
assert(defaultFill <= 0xff);
__int64 word = 0x0101010101010101LL * defaultFill;
return (T)word;