[Mono-bugs] [Bug 387274] Type verification is enforced even when SkipVerification is requested

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed May 7 04:16:50 EDT 2008


User kornelpal at gmail.com added comment

--- Comment #4 from Kornél Pál <kornelpal at gmail.com>  2008-05-07 02:16:49 MST ---
The code is:
  .locals (uint8&
modopt([mscorlib]System.Runtime.CompilerServices.IsExplicitlyDereferenced) V_0)
  IL_000a:  ldstr      "WriteStringManaged"
  IL_000f:  stloc.0
  IL_0010:  ldloc.0
  IL_0011:  brfalse.s  IL_001b
  IL_0013:  call       int32
  IL_0018:  ldloc.0
  IL_0019:  add
  IL_001a:  stloc.0

"string" is an "object reference" and "uint8&" is a "managed pointer".

I have looked at the standard: Managed pointer types: O and &

"The O data type represents an object reference that is managed by the CLI. ...
The & data type (managed pointer) is similar to the O type, but points to the
interior of an object.

[Note: In summary, object references, or O types, refer to the ‘outside’ of
an object, or to an object as-a-whole.
But managed pointers, or & types, refer to the interior of an object. The &
types are sometimes called “byref
types” in source languages, since passing a field of an object by reference
is represented in the VES by using an
& type to represent the type of the parameter. end note]"

So what MS VC++ is doing is standard compliant because both "object references"
and "managed pointers" are native sized pointers to actual memory addresses.

The same thing in C#:

fixed (char* str = "WriteStringManaged")

  .locals init ([0] char* str,
           [1] string pinned CS$519$0000)
  IL_0000:  ldstr      "WriteStringManaged"
  IL_0005:  stloc.1
  IL_0006:  ldloc.1
  IL_0007:  conv.i
  IL_0008:  dup
  IL_0009:  brfalse.s  IL_0011
  IL_000b:  call       int32
  IL_0010:  add
  IL_0011:  stloc.0

As you can see the only significant difference is an extra conv.i that does
nothing except changing type signature on the stack that is worthless because
this code is unverifiable.

So if we believe that this latter is vaild IL code we have to admit that the
earlier (MS VC++ version) is valid IL code as well.

Because this is valid IL code VerificationException rather than
InvalidProgramException should be thrown instead, that should be avoided for
the attached test case because of SkipVerification request.

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list