[Mono-bugs] [Bug 342565] New: Runtime crash in verifier.
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Sat Nov 17 17:23:01 EST 2007
https://bugzilla.novell.com/show_bug.cgi?id=342565
Summary: Runtime crash in verifier.
Product: Mono: Runtime
Version: unspecified
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: P5 - None
Component: JIT
AssignedTo: lupus at novell.com
ReportedBy: miguel at novell.com
QAContact: mono-bugs at ximian.com
Found By: ---
The following sample crashes the Mono runtime in the verifier, the code
generated is invalid, but we should not crash:
public class EmitHelloWorld{
static void Main(string[] args)
{
// create a dynamic assembly and module
AssemblyName assemblyName = new AssemblyName();
assemblyName.Name = "HelloWorld";
AssemblyBuilder assemblyBuilder =
Thread.GetDomain().DefineDynamicAssembly(assemblyName,
AssemblyBuilderAccess.RunAndSave);
ModuleBuilder module = assemblyBuilder.DefineDynamicModule("b.dll"); //
<-- pass 'true' to track debug info.
// create a new type to hold our Main method
TypeBuilder typeBuilder = module.DefineType("HelloWorldType",
TypeAttributes.Public | TypeAttributes.Class);
// create the Main(string[] args) method
MethodBuilder methodbuilder = typeBuilder.DefineMethod("Demo",
MethodAttributes.HideBySig | MethodAttributes.Static | MethodAttributes.Public,
typeof(void), new Type[] { typeof(string[]) });
// generate the IL for the Main method
ILGenerator ilGenerator = methodbuilder.GetILGenerator();
// Create a local variable of type 'string', and call it 'xyz'
LocalBuilder localXYZ = ilGenerator.DeclareLocal(typeof(string));
// Emit sequence point before the IL instructions. This is start line,
start col, end line, end column,
// Line 2: xyz = "hello";
ilGenerator.Emit(OpCodes.Ldstr, "Hello world!");
ilGenerator.Emit(OpCodes.Stloc, localXYZ);
// Line 3: Write(xyz);
MethodInfo infoWriteLine =
typeof(System.Console).GetMethod("WriteLine", new Type[] { typeof(string) });
ilGenerator.Emit(OpCodes.Ldloc, localXYZ);
ilGenerator.EmitCall(OpCodes.Call, infoWriteLine, null);
SignatureHelper sh = SignatureHelper.GetMethodSigHelper (module,
(CallingConventions) 0, typeof (int));
ilGenerator.Emit (OpCodes.Call, sh);
// Line 4: return;
ilGenerator.Emit(OpCodes.Ret);
// bake it
Type helloWorldType = typeBuilder.CreateType();
assemblyBuilder.Save ("b.dll");
// This now calls the newly generated method. We can step into this and
debug our emitted code!!
helloWorldType.GetMethod("Demo").Invoke(null, new string[] { null });
// <-- step into this call
}
}
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
More information about the mono-bugs
mailing list