Fix JIT crash with static function accessing non-static field
authorSejong Oh <sejooh@microsoft.com>
Wed, 6 Apr 2016 00:52:14 +0000 (17:52 -0700)
committerSejong Oh <sejooh@microsoft.com>
Mon, 11 Apr 2016 18:45:54 +0000 (11:45 -0700)
commit30d8dece857cd5455ea4a046f2b81e85af323d55
tree6b83d97c8703f6dced15fa8e38924a71eed383d9
parent1612340366458ef1650e73374e2502187c5db0e6
Fix JIT crash with static function accessing non-static field

The IL below is invalid since the static function acceses the non-static
field. On Desktop CRL, JIT throws a verification exception. However, CoreCLR
doesn't support verification and JIT crashes. This fix makes JIT throw a
invalid program exception if verification is disabled.

.field int32 i
.method static int32 f()
{
ldsfld int32 Test::i
ret
}

The test also expects InvalidProgramException instead of
VerificationException.

Commit migrated from https://github.com/dotnet/coreclr/commit/0e3eb21c2266abb55b1490f0231a2ad59bfc1aba
src/coreclr/src/jit/importer.cpp
src/coreclr/tests/issues.targets
src/coreclr/tests/src/JIT/Directed/coverage/importer/Desktop/badldsfld.il
src/coreclr/tests/testsFailingOutsideWindows.txt