Guard a use of a possibly-uninitialized BitSet.
authorPat Gavlin <pagavlin@microsoft.com>
Wed, 1 Mar 2017 04:51:07 +0000 (20:51 -0800)
committerPat Gavlin <pagavlin@microsoft.com>
Wed, 1 Mar 2017 04:51:07 +0000 (20:51 -0800)
Part of the range check optimization pass was not checking to ensure that a bitset
was initialized before attempting to access it. This was causing one of the new
tests for Vector.Narrow to fail with an AV.

Commit migrated from https://github.com/dotnet/coreclr/commit/06cdb2191857b6fab899b8ae1150604447e064ad

src/coreclr/src/jit/rangecheck.cpp

index 8d16cce..22b5328 100644 (file)
@@ -869,10 +869,13 @@ Range RangeCheck::ComputeRangeForLocalDef(
         case GT_ASG:
         {
             Range range = GetRange(loc->block, loc->stmt, asg->gtGetOp2(), path, monotonic DEBUGARG(indent));
-            JITDUMP("Merge assertions from BB%02d:%s for assignment about %p\n", block->bbNum,
-                    BitVecOps::ToString(m_pCompiler->apTraits, block->bbAssertionIn), dspPtr(asg->gtGetOp1()));
-            MergeEdgeAssertions(asg->gtGetOp1(), block->bbAssertionIn, &range);
-            JITDUMP("done merging\n");
+            if (!BitVecOps::MayBeUninit(block->bbAssertionIn))
+            {
+                JITDUMP("Merge assertions from BB%02d:%s for assignment about %p\n", block->bbNum,
+                        BitVecOps::ToString(m_pCompiler->apTraits, block->bbAssertionIn), dspPtr(asg->gtGetOp1()));
+                MergeEdgeAssertions(asg->gtGetOp1(), block->bbAssertionIn, &range);
+                JITDUMP("done merging\n");
+            }
             return range;
         }