Re: IL code fails with VerificationException




"Paul Hatcher" <paulh@xxxxxxxxxxxxx> wrote in message
news:O7h5l0S7GHA.1492@xxxxxxxxxxxxxxxxxxxxxxx
Hi

We have a requirement to get the non-virtual version of GetHashCode for
any object (value or reference type). There is a call
System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode, but this fails
under some circumstances on 1.1 when passed Int32 and so we have some IL
code to achieve the same thing.

Unforturnately under medium trust, this fails with a
VerificationException, which I belive means that it can't determine
whether we are type safe or not. Can anyone help and tell me if this is
type-safe and if so how to pass the security check.

What is the output of PEVerify?


BTW The assembly is signed and has the AllowPartiallyTrustedCaller and
CLSCompliant attributes applied (I've left these out of the IL for space
purposes)

Paul

--------------
.namespace Utility
{
.class public serializable IdentityHashCodeProvider
implements [mscorlib]System.Collections.IHashCodeProvider
{
.method private hidebysig newslot final virtual
instance int32
System.Collections.IHashCodeProvider.GetHashCode(object obj)
{
.override [mscorlib]System.Collections.IHashCodeProvider::GetHashCode
ldarg.1
call instance int32 [mscorlib]System.Object::GetHashCode()
ret
}

.method public hidebysig specialname rtspecialname instance void
.ctor()
{
ldarg.0
call instance void [mscorlib]System.Object::.ctor()
ret
}
}
}



.



Relevant Pages

  • IL code fails with VerificationException
    ... object (value or reference type). ... Unforturnately under medium trust, this fails with a VerificationException, ... .method public hidebysig specialname rtspecialname instance void .ctor ...
    (microsoft.public.dotnet.security)
  • [PATCH] Fix infinite loop in quota
    ... Attached patch fixes possible infinite loop in dqputwhen quota code ... fails to start a transaction on a filesystem. ... If we fail to start a transaction when releasing dquot, ... ret = dquot_release; ...
    (Linux-Kernel)
  • [PATCH] fix invalidate_inode_pages2_range not to clear ret
    ... DIO invalidates page cache through invalidate_inode_pages2_range. ... but this ret is cleared if do_launder_pagesucceed on a page of next index. ... dio is carried out even if invalidate_complete_page2fails on some pages. ...
    (Linux-Kernel)
  • [RESEND] [PATCH] fix invalidate_inode_pages2_range not to clear ret
    ... DIO invalidates page cache through invalidate_inode_pages2_range. ... but this ret is cleared if do_launder_pagesucceed on a page of next index. ... dio is carried out even if invalidate_complete_page2fails on some pages. ...
    (Linux-Kernel)