Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any method with a local variable crashes #47

Closed
toptensoftware opened this issue May 17, 2019 · 3 comments
Closed

Any method with a local variable crashes #47

toptensoftware opened this issue May 17, 2019 · 3 comments

Comments

@toptensoftware
Copy link
Contributor

Adding a reference to the rewritten dll from pull request #43 and calling the IntMethod() crashes with System.InvalidProgramException: Common Language Runtime detected an invalid program.

            var x = new MyClass();
            x.IntMethod();

Looking at the ildasm listing shows the locals haven't been defined. Here's the original (note the .locals line)

.method public hidebysig instance int32 
          IntMethod() cil managed
  {
    // Code size       7 (0x7)
    .maxstack  1
    .locals init (int32 V_0)
    IL_0000:  nop
    IL_0001:  ldc.i4.0
    IL_0002:  stloc.0
    IL_0003:  br.s       IL_0005

    IL_0005:  ldloc.0
    IL_0006:  ret
  } // end of method MyClass::IntMethod

here's the rewritten version: (no .locals)

  .method public hidebysig instance int32 
          IntMethod() cil managed
  {
    // Code size       7 (0x7)
    .maxstack  8
    IL_0000:  nop
    IL_0001:  ldc.i4.0
    IL_0002:  stloc.0
    IL_0003:  br.s       IL_0005

    IL_0005:  ldloc.0
    IL_0006:  ret
  } // end of method MyClass::IntMethod

Also, .maxstack is different and wondering if this is just a default and if there might be issues if the function needs more than 8??

@toptensoftware
Copy link
Contributor Author

I'm guessing this line is the reason for this:

var localVariablesSignature = default(StandaloneSignatureHandle);

@toptensoftware
Copy link
Contributor Author

Pull request #48 fixes this.

@vermorel
Copy link
Member

Confirmed with Ildasm as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants