Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3990906
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:33:03+00:00 2026-05-20T06:33:03+00:00

I’m getting a weird bug in an assembly exported with System.Reflection.Emit with mono. When

  • 0

I’m getting a weird bug in an assembly exported with System.Reflection.Emit with mono.
When attempting to run my assembly, I get an InvalidProgramException: Invalid IL code.

monodis gives me this CIL result(which is consistent with what I export with Emit):

.method public static hidebysig 
       default void f_main (class [Pine.Core]Pine.Core.Function A_0, class [Pine.Core]Pine.Core.ValueList A_1)  cil managed 
{
    // Method begins at RVA 0x2144
    // Code size 26 (0x1a)
    .maxstack 4
    .locals init (
        class [Pine.Core]Pine.Core.Function V_0,
        class [Pine.Core]Pine.Core.IScope   V_1,
        class [Pine.Core]Pine.Core.ValueList    V_2,
        class [Pine.Core]Pine.Core.IScope   V_3)
    IL_0000:  ldarg.0 
    IL_0001:  stloc.0 
    IL_0002:  ldarg.1 
    IL_0003:  stloc.2 
    IL_0004:  ldloc.0 
    IL_0005:  ldftn instance class [Pine.Core]Pine.Core.IScope class [Pine.Core]Pine.Core.Function::get_Scope()
    IL_000b:  stloc.1 
    IL_000c:  ldloc.1 
    IL_000d:  newobj instance void class [Pine.Core]Pine.Core.BlockScope::'.ctor'(class [Pine.Core]Pine.Core.IScope)
    IL_0012:  stloc.3 
    IL_0013:  ldloc.2 
    IL_0014:  call instance void class [Pine.Core]Pine.Core.ValueList::Clear()
    IL_0019:  ret 
} // end of method PineType::f_main

The error happens in IL_000b: stloc.1
I have no idea why.

I tried to replace the stloc.1 by a pop instruction. When I do that the error happens in IL_0019: ret

I really don’t know why this is behaving like this. Any ideas?

Additional Information:

  • IScope is an interface
  • BlockScope implements IScope
  • Function has a public IScope Scope { get; private set; }
  • I get this error with both Mono 2.6.7(Boehm, AMD64) and Mono 2.8(Boehm with typed GC and Parallel Mark, AMD64)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T06:33:04+00:00Added an answer on May 20, 2026 at 6:33 am

    Edit: judging from the code, perhaps IL_0005 is meant to be a call/callvirt and not a ldftn? Perhaps the emitting is using the wrong opcode?

    Local 1 is an IScope. ldftn pushes a function pointer (native int) onto the evaluation stack. The store instruction at IL_000b fails verifiability, as a native int is not verifier-assignable-to IScope.

    As for your second problem, you’ve unbalanced the evaluation stack with the instruction at IL_0004. ldftn’s stack transition is ” … -> …, ftn”. Meaning it doesn’t take an evaluation stack argument, only the immediate metadata token. By changing IL_000b to a pop, you pop what ldftn pushed, but not what IL_0004 pushed.

    What isn’t clear to me is what you’re attempting to do. You can’t treat a single function pointer as an interface (which you could think of, conceptually at least, as a pointer to a v-table). You would need to instantiate a type that implements the interface. What you could do with the function pointer is create a delegate from it – Delegate has an (object, native int) overload for .ctor. That would be where I assume the object reference pushed by IL_0004 would come into play (first argument to this .ctor). You could, of course, calli the function pointer directly as well. As I am unfamiliar with this object model you’re interacting with, I can’t say what the right approach is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I would like to run a str_replace or preg_replace which looks for certain words
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.