Eliminate SEH interactions between the JIT and the EE during verification.
authorPat Gavlin <pagavlin@microsoft.com>
Fri, 29 Apr 2016 20:23:52 +0000 (13:23 -0700)
committerPat Gavlin <pagavlin@microsoft.com>
Fri, 29 Apr 2016 20:23:52 +0000 (13:23 -0700)
commitf3a2277c8c37a29417562cfa478935ddbb801fe7
treeb58c58a12bb30f832222426ae487992f21dd103b
parent23d0b7a74a67094c070af3477d06677bf19173d0
Eliminate SEH interactions between the JIT and the EE during verification.

For compatibility reasons, `BadImageFormatException`s that are thrown when resolving tokens
during verification are transformed instead into verification exceptions. This transformation
currently takes place in the JIT: the JIT wraps relevant calls to `ICorJitInfo::resolveToken` with
a `__try`/`__except` that handles any exceptions that arise due to invalid metadata. This method
cannot be relied on when consuming the JIT as a dynamic library on non-Windows platforms
due to type identity problems in the runtime's SEH emulation. Furthermore, these filters cannot
use the proposed solution to the JIT's other uses of SEH across the JIT/EE interface, since they
are more complex than a call to `ICorJitInfo::FilterException`. Instead, this change introduces a
new method, `ICorJitInfo::tryResolveToken`, which is only used during verification. This method
implements filtering that is equivalent to the current implementation, but does so in the EE rather
than in the JIT.

This is part of GitHub bugs #3058 and #4130.

[tfs-changeset: 1600443]
src/inc/corinfo.h
src/jit/compiler.h
src/jit/ee_il_dll.cpp
src/jit/importer.cpp
src/vm/jitinterface.cpp
src/vm/jitinterface.h
src/zap/zapinfo.cpp
src/zap/zapinfo.h