[Mono-bugs] [Bug 53893][Nor] New - NullReferenceException from embedded api, but not from the mono JIT
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Wed, 4 Feb 2004 16:49:06 -0500 (EST)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by zealy@freemail.hu.
http://bugzilla.ximian.com/show_bug.cgi?id=53893
--- shadow/53893 2004-02-04 16:49:06.000000000 -0500
+++ shadow/53893.tmp.16947 2004-02-04 16:49:06.000000000 -0500
@@ -0,0 +1,104 @@
+Bug#: 53893
+Product: Mono/Runtime
+Version: unspecified
+OS: Debian Woody
+OS Details: dist-upgraded to sid
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: zealy@freemail.hu
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: NullReferenceException from embedded api, but not from the mono JIT
+
+Description of Problem:
+The followings apply both to mono 0.30 built from source and the official
+debian package mono 0.29.999.
+When using libmono to call methods of .NET classes from within C, on the
+first attempt to use globalisation (using the type System.String in my
+case), an exception NullReferenceException is thrown in
+System.Globalization.CultureInfo. (See the section Actual output below for
+details).
+The "equivalent" C# code works as expected.
+
+Steps to reproduce the problem:
+1. Compile the following C code
+#include <glib.h>
+#include <mono/jit/jit.h>
+#include <mono/metadata/object.h>
+#include <mono/metadata/debug-helpers.h>
+#include <mono/metadata/appdomain.h>
+
+extern void *mono_jit_trace_calls;
+
+int main(int argc, char **argv)
+{
+ gchar* str = "What bug?";
+ gpointer params[1];
+
+ MonoDomain *domain = NULL;
+ domain = mono_jit_init ("gotbug");
+
+ MonoAssembly *assembly = NULL;
+ assembly = mono_domain_assembly_open (domain, "/usr/lib/mscorlib.dll");
+
+// uncomment to enable tracing
+// mono_jit_trace_calls=mono_trace_parse_options(assembly, "");
+//
+
+ MonoClass *class;
+ class = (MonoClass*) mono_class_from_name (assembly-
+>image, "System", "Console");
+ mono_class_init (class);
+
+ static MonoMethod *method;
+ MonoMethodDesc *desc = mono_method_desc_new (":WriteLine(string)",
+FALSE);
+ method = mono_method_desc_search_in_class (desc, class);
+
+ params[0] = (gpointer*) mono_string_new (domain, str);
+
+ mono_runtime_invoke (method, NULL, params, NULL);
+ return 0;
+}
+
+
+2. Compile the following .cs code
+using System;
+
+public class GotBug
+{
+ static int Main(string[] args)
+ {
+ Console.WriteLine("What bug?");
+ return 0;
+ }
+}
+
+
+
+3. Compare the outputs of the above programs
+
+Actual Results:
+
+Unhandled Exception: System.TypeInitializationException: An exception was
+thrown by the type initializer for System.Console --->
+System.NullReferenceException: A null value was found where an object
+instance was required
+in <0x0000f> System.Globalization.CultureInfo:get_CurrentCulture ()
+in <0x00010> System.String:ToUpper ()
+in <0x0003f> System.Console:.cctor ()
+--- End of inner exception stack trace ---
+
+Expected Results:
+"What bug?" echoed on the tty
+
+How often does this happen?
+Always
+
+Additional Information: