Bugzilla – Bug 311403
infinite loop with marshal2.cs on ms runtime
Last modified: 2007-09-15 21:24:23 UTC
---- Reported by lupus@ximian.com 2002-08-23 11:28:34 MST ---- marshal2.cs in mono/mono/tests doesn't compile with mcs running with the ms runtime (it seems to just sit there like in an infinite loop or a wait). With the mono runtime it gives an exception: Unhandled Exception: System.IndexOutOfRangeException: Array index is out of range in <0x00066> 00 System.Reflection.Emit.TypeBuilder:string_from_bytes (byte[],int,int) in <0x0031a> 00 System.Reflection.Emit.TypeBuilder:SetCustomAttribute (System.Reflection.Emit.CustomAttributeBuilder) in <0x0086f> 00 Mono.CSharp.Attribute:ApplyAttributes (Mono.CSharp.EmitContext,object,object,Mono.CSharp.Attributes,Mono.CSharp.Location) in <0x0088b> 00 Mono.CSharp.TypeContainer:Emit () in <0x004f5> 00 Mono.CSharp.RootContext:EmitCode () in <0x00833> 00 Mono.CSharp.Driver:MainDriver (string[]) in <0x00019> 00 Mono.CSharp.Driver:Main (string[]) Though that may be a bug in reflection I'd prefer to debug it knowing mcs can compile it fine. ---- Additional Comments From martin@gnome.org 2002-08-23 14:32:36 MST ---- Looks like the same than the test-120.cs crash. Can you please debug this, I already tried one or two weeks ago and found out that it crashes somewhere inside System.Reflection.Emit but I was unable to find out why. The crash seems to happen while encoding the attribute, but since I don't have any idea how an attribute is encoded it's very hard for me to know what goes wrong when debugging it. ---- Additional Comments From gonzalo@ximian.com 2002-08-25 12:31:24 MST ---- In the for loop (line 641 in TypeBuilder), there is a line that says: byte type = data [pos++]; well, displaying byte [] data tells that at the position where it gets the length (ie, after that line) we have: pos = 9 -> 17 pos = 10 -> 7 pos = 11 to 17 -> C h a r S e t so if you add a 'pos++; after the line #641, mcs is able to compile it (because the length of "CharSet" is encoded at pos 10, not 9). May be the 17 at pos 9 tells where the next parameter information ends??? MS runtime still keeps looping or waiting, but may i hope you find this info useful. ---- Additional Comments From miguel@ximian.com 2002-08-26 18:09:57 MST ---- Moved to the runtime category ---- Additional Comments From lupus@ximian.com 2002-08-27 11:01:57 MST ---- I fixed the bug in our runtime, now both marshal2.cs and test-120.cs gets compiled correctly by mcs while running on the mono runtime. It still loops somewhere when running on the ms runtime so the bug goes back to Mono/MCS. ---- Additional Comments From martin@gnome.org 2002-08-27 19:58:31 MST ---- Did you fix it in our runtime or did you add a workaround for it ? If you actually fixed it, then what should I do in MCS - in this case, the ms runtime has a bug and is unable to encode this attribute, right ? Now the question is what we should do. Maybe we need to check whether we're using the mono runtime and not create the attribute otherwise or what do you think ? IMO we should'nt attempt to emit the attribute if it's yielding a stack overflow on the ms runtime, that'd make mcs unusable with it. ---- Additional Comments From martin@gnome.org 2002-09-26 07:49:17 MST ---- Setting priority to wishlist, see my last comment. ---- Additional Comments From martin@ximian.com 2002-11-16 18:14:29 MST ---- Expiring this bug after waiting two months for instructions. ---- Additional Comments From lupus@ximian.com 2002-11-17 05:38:39 MST ---- The instructions are above: compile marshal2.cs with the ms runtime and you'll get a hang. I don't know if it's a mcs bug or a bug in the ms runtime, you'll have to debug it and find out what really happens. ---- Additional Comments From bmaurer@users.sf.net 2003-12-24 22:56:34 MST ---- Created an attachment (id=164327) Now it works -- finally ;-) ---- Additional Comments From bmaurer@users.sf.net 2003-12-24 22:58:08 MST ---- This patch does two things: 1) set the attribute directly for MarshalAs Microsoft seems to hang when we set it via the custom attribute builder 2) complete the todo for handling all the cases of this attribute. This prevents regressions. ---- Additional Comments From bmaurer@users.sf.net 2004-01-03 13:05:54 MST ---- Fixed in CVS! (about time :). ---- Additional Comments From bmaurer@users.sf.net 2004-01-04 00:52:56 MST ---- I said FIXED ;-) Imported an attachment (id=164327) Unknown operating system other. Setting to default OS "Other".