[Ironruby-core] Regression ? "Invalid IL code in (wrapper dynamic-method)"

Tomas Matousek Tomas.Matousek at microsoft.com
Tue Mar 3 00:45:56 EST 2009


This issue is now fixed in the GIT repo.

Tomas

-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Tomas Matousek
Sent: Friday, February 27, 2009 2:53 PM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Regression ? "Invalid IL code in (wrapper dynamic-method)"

There is a bug in DLR compiler. We are working on a fix.

Thanks for great report,
Tomas

-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Jb Evain
Sent: Friday, February 27, 2009 11:47 AM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Regression ? "Invalid IL code in (wrapper dynamic-method)"

Hey Tomas,

On 2/27/09, Tomas Matousek <Tomas.Matousek at microsoft.com> wrote:
>  Jb, could you try again using the latest source code (after Jim pushes it) and if it fails send me please full stack trace and complete IL of the offending method?

Sure.

So, after building from source the updated git repo, we have a
different error, but similar error.

I'm simply executing mono ir.exe test.rb, where test.rb only contains
a call to `require "mscorlib"`.

The stacktrace looks like this:

(gdb) bt
#0  mono_method_to_ir (cfg=0x8ec0ac0, method=0x8ecbce8,
start_bblock=0x8ec48b4, end_bblock=0x8ec494c, return_var=0x0,
dont_inline=0x8ec9a60, inline_args=0x0, inline_offset=0,
is_virtual_call=0)at method-to-ir.c:4606
#1  0x0806124d in mini_method_compile (method=0x8ecbce8,
opts=64055807, domain=0x25ee0, run_cctors=<value optimized out>,
compile_aot=<value optimized out>, parts=0) at mini.c:3208
#2  0x08062b19 in mono_jit_compile_method (method=0x8ecbce8) at mini.c:3847
#3  0x0818ef88 in ves_icall_System_Delegate_CreateDelegate_internal
(type=0xc6960, target=0x1f27b0, info=0x2e0a0) at icall.c:5988
#4  0xb6c9ae43 in (wrapper managed-to-native)
System.Delegate:CreateDelegate_internal (param0=0xc6960,
param1=0x1f27b0, param2=0x2e0a0) at xdb.il:7790
#5  0xb6c9ab34 in System.Delegate:CreateDelegate (type=0xc6960,
firstArgument=0x1f27b0, method=0x2e0a0, throwOnBindFailure=true)at
/home/jbevain/sources/mcs/class/corlib/System/Delegate.cs:256
#6  0xb6c9a6e6 in System.Delegate:CreateDelegate (type=0xc6960,
firstArgument=0x1f27b0, method=0x2e0a0) at
/home/jbevain/sources/mcs/class/corlib/System/Delegate.cs:263
#7  0xb6bc152b in System.Reflection.Emit.DynamicMethod:CreateDelegate
(this=0x2e0a0, delegateType=0xc6960, target=0x1f27b0) at
/home/jbevain/sources/mcs/class/corlib/System.Reflection.Emit/DynamicMethod.cs:189
#8  0xb6bc14c8 in System.Dynamic.Utils.TypeExtensions:CreateDelegate
(methodInfo=0x2e0a0, delegateType=0xc6960, target=0x1f27b0) at
xdb.il:44617
#9  0xb6bc13d7 in
System.Linq.Expressions.Compiler.LambdaCompiler:CreateDelegate
(this=0x1f17e0) at xdb.il:44564
#10 0xb6bcb61f in
System.Linq.Expressions.Compiler.LambdaCompiler:Compile
(lambda=0x1f0ca0) at xdb.il:34475
#11 0xb6bcb57c in System.Linq.Expressions.Expression`1<object>:Compile
(this=0x1f0ca0)
#12 0xb6b722ba in System.Dynamic.SmallRuleSet`1<object>:MakeTarget
(this=0x1f3c60)
#13 0xb6b72235 in System.Dynamic.SmallRuleSet`1<object>:GetTarget
(this=0x1f3c60)
#14 0xb6b721ea in
System.Runtime.CompilerServices.CallSiteOps:SetTarget<object>(site=1120512,
rule=2047096)
#15 0xb6bc293b in
System.Dynamic.UpdateDelegates:UpdateAndExecute3<object, object,
object, object> (site=0xe9940, arg0=0x5ab80, arg1=0x50cf0,
arg2=0x111528)
#16 0xb6bbe81c in (wrapper static-rgctx-invoke)
System.Dynamic.UpdateDelegates:static_rgctx_invoke_object_CallSite_RubyScope_object_MutableString
(param0=0x111900, param1=0x5ab80, param2=0x50cf0, param3=0x111528)at
xdb.il:43447
#17 0xb6ba3120 in (wrapper dynamic-method) object:IR;#;test.rb;0;
(param0=0xe9ab0, param1=0x111d50, param2=0x25aa0) at xdb.il:44669
#18 0xb6bcb2b8 in Microsoft.Scripting.ScriptCode:InvokeTarget
(this=0x111d68, code=0x4e700, scope=0x111d50) at xdb.il:34374
#19 0xb6bcb279 in Microsoft.Scripting.ScriptCode:Run (this=0x111d68,
scope=0x111d50) at xdb.il:34361
#20 0xb6bcb1f3 in Microsoft.Scripting.ScriptCode:Run (this=0x111d68)
at xdb.il:34331
#21 0xb6beac36 in IronRuby.Runtime.RubyContext:ExecuteProgram
(this=0x25aa0, program=0xe2eb0) at xdb.il:17847
#22 0xb6beab8d in
Microsoft.Scripting.Hosting.ScriptSource:ExecuteProgram (this=0x8b978)
at xdb.il:17816
#23 0xb6beab2c in (wrapper remoting-invoke-with-check)
Microsoft.Scripting.Hosting.ScriptSource:ExecuteProgram (this=0x8b978)
at xdb.il:17807
#24 0xb6beaa4e in
Microsoft.Scripting.Hosting.Shell.CommandLine:RunFile (this=0xe2f00,
source=0x8b978) at xdb.il:17749
#25 0xb6bea389 in IronRuby.Hosting.RubyCommandLine:RunFile
(this=0xe2f00, fileName=0x48fe0) at xdb.il:17406
#26 0xb6bea2d2 in Microsoft.Scripting.Hosting.Shell.CommandLine:Run
(this=0xe2f00) at xdb.il:17363
#27 0xb6bea103 in Microsoft.Scripting.Hosting.Shell.CommandLine:Run
(this=0xe2f00, engine=0x4e880, console=0xe2ed8, options=0x4b320) at
xdb.il:17265
#28 0xb6be5570 in
Microsoft.Scripting.Hosting.Shell.ConsoleHost:RunCommandLine(this=0x4bfc8)
at xdb.il:16737
#29 0xb6be5370 in
Microsoft.Scripting.Hosting.Shell.ConsoleHost:ExecuteInternal(this=0x4bfc8)
at xdb.il:16638
#30 0xb6be520e in
Microsoft.Scripting.Hosting.Shell.ConsoleHost:Execute (this=0x4bfc8)
at xdb.il:16568
#31 0xb780b81b in Microsoft.Scripting.Hosting.Shell.ConsoleHost:Run
(this=0x4bfc8, args=0x29f48) at xdb.il:276
#32 0xb780b2ca in RubyConsoleHost:Main (args=0x29f48) at xdb.il:79
#33 0xb780b203 in (wrapper runtime-invoke)
RubyConsoleHost:runtime_invoke_int_object (param0=<value optimized
out>, param1=-1073746312, param2=0, param3=-1216302424) at xdb.il:53
#34 0x0814551e in mono_runtime_exec_main (method=0x82cdde4,
args=0x29f48, exc=0x0) at object.c:3335
#35 0x08145c3b in mono_runtime_run_main (method=0x82cdde4, argc=1,
argv=0xbffff0d8, exc=0x0) at object.c:3123
#36 0x080b1b0a in mono_main (argc=3, argv=0xbffff0d4) at driver.c:969
#37 0x0805aff1 in main (argc=149723456, argv=0x0) at main.c:34
(gdb)

And most importantly, the code that is trying to be emitted by the
DynamicMethod is as follows:

(gdb) p mono_method_get_header(method)->code
$1 = (const unsigned char *) 0x8ec15e0 "\005\002{\001"
(gdb) p mono_method_get_header(method)->code_size
$2 = 198
(gdb) p mono_disasm_code (0, method, 0x8ec15e0, 0x8ec15e0 + 198)
IL_0000: ldarg.3
IL_0001: ldarg.0
IL_0002: ldfld     <System.Runtime.CompilerServices.Closure:Constants>
IL_0007: ldc.i4.0
IL_0008: ldelem.ref
IL_0009: ceq
IL_000b: brfalse   IL_00a3
IL_0010: ldarg.2
IL_0011: call      <IronRuby.Runtime.RubyOps:GetContextFromScope
(IronRuby.Runtime.RubyScope)>
IL_0016: ldarg.0
IL_0017: ldfld     <System.Runtime.CompilerServices.Closure:Constants>
IL_001c: ldc.i4.1
IL_001d: ldelem.ref
IL_001e: castclass <RubyContext>
IL_0023: ceq
IL_0025: brfalse   IL_00a3
IL_002a: ldarg.s   4
IL_002c: brfalse   IL_00a3
IL_0031: ldarg.s   4
IL_0033: castclass <Object>
IL_0038: callvirt  <object:GetType ()>
IL_003d: ldtoken   <IronRuby.Builtins.MutableString>
IL_0042: call      <System.Type:GetTypeFromHandle (System.RuntimeTypeHandle)>
IL_0047: ceq
IL_0049: brfalse   IL_00a3
IL_004e: ldarg.0
IL_004f: ldfld     <System.Runtime.CompilerServices.Closure:Constants>
IL_0054: ldc.i4.2
IL_0055: ldelem.ref
IL_0056: castclass <StrongBox`1>
IL_005b: ldfld     <System.Runtime.CompilerServices.StrongBox`1:Value>
IL_0060: ldc.i4    189
IL_0065: ceq
IL_0067: brfalse   IL_009d
IL_006c: ldarg.2
IL_006d: ldarg.3
IL_006e: ldarg.0
IL_006f: ldfld     <System.Runtime.CompilerServices.Closure:Constants>
IL_0074: ldc.i4.3
IL_0075: ldelem.ref
IL_0076: castclass <CallSite`1>
IL_007b: dup
IL_007c: stloc.0
IL_007d: ldfld     <System.Runtime.CompilerServices.CallSite`1:Target>
IL_0082: ldloc.0
IL_0083: ldarg.2
IL_0084: call      <IronRuby.Runtime.RubyOps:GetContextFromScope
(IronRuby.Runtime.RubyScope)>
IL_0089: ldarg.s   4
IL_008b: callvirt
<System.Func`4<System.Runtime.CompilerServices.CallSite,
IronRuby.Runtime.RubyContext, IronRuby.Builtins.MutableString,
IronRuby.Builtins.MutableString>:Invoke
(System.Runtime.CompilerServices.CallSite,IronRuby.Runtime.RubyContext,IronRuby.Builtins.MutableString)>
IL_0090: call      <IronRuby.Builtins.KernelOps:Require
(IronRuby.Runtime.RubyScope,object,IronRuby.Builtins.MutableString)>
IL_0095: tail.
IL_0097: call
<Microsoft.Scripting.Runtime.ScriptingRuntimeHelpers:BooleanToObject
(bool)>
IL_009c: ret
IL_009d: br        IL_00a3
IL_00a2: ret
IL_00a3: ldarg.1
IL_00a4: call
<System.Runtime.CompilerServices.CallSiteOps:NeedsUpdate
(System.Runtime.CompilerServices.CallSite)>
IL_00a9: brfalse   IL_00b0
IL_00ae: ldnull
IL_00af: ret
IL_00b0: ldarg.1
IL_00b1: castclass <CallSite`1>
IL_00b6: callvirt
<System.Runtime.CompilerServices.CallSite`1<System.Func`5<System.Runtime.CompilerServices.CallSite,
IronRuby.Runtime.RubyScope, object, IronRuby.Builtins.MutableString,
object>>:get_Update ()>
IL_00bb: ldarg.1
IL_00bc: ldarg.2
IL_00bd: ldarg.3
IL_00be: ldarg.s   4
IL_00c0: callvirt
<System.Func`5<System.Runtime.CompilerServices.CallSite,
IronRuby.Runtime.RubyScope, object, IronRuby.Builtins.MutableString,
object>:Invoke (System.Runtime.CompilerServices.CallSite,IronRuby.Runtime.RubyScope,object,IronRuby.Builtins.MutableString)>
IL_00c5: ret

The issue here is the instruction:

IL_00a2: ret

With is right after an unconditional branch, thus will be executed,
but the IL is still wrong.

-- 
Jb Evain  <jb at nurv.fr>
_______________________________________________
Ironruby-core mailing list
Ironruby-core at rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core

_______________________________________________
Ironruby-core mailing list
Ironruby-core at rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core



More information about the Ironruby-core mailing list