for loop index pinned?

Dec 6, 2009 at 9:13 AM

Is it normal that a local variable used in a "for" loop gets pinned?
.method public hidebysig static void $Main() cil managed
.maxstack 2
.locals init (
[0] int32 pinned num)
L_0000: ldc.i4.0
L_0001: stloc.0
L_0002: br.s L_0018
L_0004: ldstr "Repeat index: {0}"
L_0009: ldloc.0
L_000a: box int32
L_000f: call void [mscorlib]System.Console::WriteLine(string, object)
L_0014: ldloc.0
L_0015: ldc.i4.1
L_0016: add
L_0017: stloc.0
L_0018: ldloc.0
L_0019: ldc.i4.s 20
L_001b: blt.s L_0004
L_001d: ldstr "Bye"
L_0022: call void [mscorlib]System.Console::WriteLine(string)
L_0027: ret

Dec 6, 2009 at 5:54 PM

No this is not normal. Somehow, it seems, the local variable definition for "num" reported true for the IsPinned property. I can't find any place in the CCI code where that would happen, so it may be worthwhile to look if your code might be involved. At any rate, do some debugging looking at how PeWriter gets a true value for IsPinned. If the problem is due to CCI code, please provide me with with a test case that illustrates the bad behavior.