[Mono-bugs] [Bug 434606] New: Uses of System.Diagnostics. TraceSwitch from static class initializers fail when running in embedded mode
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Sun Oct 12 12:12:27 EDT 2008
https://bugzilla.novell.com/show_bug.cgi?id=434606
Summary: Uses of System.Diagnostics.TraceSwitch from static class
initializers fail when running in embedded mode
Product: Mono: Class Libraries
Version: 2.0
Platform: All
OS/Version: Red Hat 9.0
Status: NEW
Severity: Normal
Priority: P5 - None
Component: System
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: lortiz at interactivesupercomputing.com
QAContact: mono-bugs at lists.ximian.com
Found By: Development
Created an attachment (id=245024)
--> (https://bugzilla.novell.com/attachment.cgi?id=245024)
File to demonstrate the bug
I have a rather complicated embedded mono application that was running happily
with Mono 1.2.6, both from a command line version and in an embedded mono
environment. I had been running the Mono 2.0 release from the command line as
well, with no problems. But when I tried to run the application in the
embedded environment, it blew up with:
System.TypeInitializationException: An exception was thrown by the type
initializer for java.lang.System ---> System.TypeInitializationException: An
exception was thrown by the type initializer for
IKVM.NativeCode.java.lang.Thread --->
System.Reflection.TargetInvocationException: Exception has been thrown by the
target of an invocation. ---> System.TypeInitializationException: An exception
was thrown by the type initializer for java.lang.Thread --->
System.TypeInitializationException: An exception was thrown by the type
initializer for java.lang.Float ---> System.TypeInitializationException: An
exception was thrown by the type initializer for
IKVM.Internal.ClassLoaderWrapper --->
System.Configuration.ConfigurationErrorsException: Error Initializing the
configuration system. ---> System.NullReferenceException: Object reference not
set to an instance of an object
I distilled down the problem to a change in the
System.Configuration.ConfigurationManager handles the cases where application
name may not be availible.
In Mono 2.0:
lfo at aztlan:~/MonoTest$ make
g++ -g -o engine -I/usr/local/include/mono-1.0 -I/usr/include/glib-2.0
-I/usr/lib/glib-2.0/include engine.cc -lmono -lpthread -lrt -ldl -lpthread -lm
gmcs -target:library -r:System.Configuration.dll driver.cs
driver.cs(37,17): warning CS0169: The private method `EngineDriver.Invoke()' is
never used
driver.cs(12,19): warning CS0414: The private field `EngineDriver.confFile' is
assigned but its value is never used
driver.cs(13,19): warning CS0414: The private field `EngineDriver.appName' is
assigned but its value is never used
driver.cs(14,21): warning CS0414: The private field `EngineDriver.eAssem' is
assigned but its value is never used
driver.cs(15,21): warning CS0414: The private field `EngineDriver.cAssem' is
assigned but its value is never used
driver.cs(16,19): warning CS0414: The private field `EngineDriver.sillyString'
is assigned but its value is never used
Compilation succeeded - 6 warning(s)
first argument is location of mono root, second is the path to the dll
/engine /usr/local `pwd`/driver.dll
mono_jit_init()
mono_domain_assembly_open
mono_class_from_name()
mono_class_describe_statics(m_driverClass); // Before Invoke
At 0xdcf48 (ofs: 0) confFile: (null)
At 0xdcf4c (ofs: 4) appName: (null)
At 0xdcf50 (ofs: 8) eAssem: (null)
At 0xdcf54 (ofs: 12) cAssem: (null)
At 0xdcf58 (ofs: 16) sillyString: (null)
At 0xdcf5c (ofs: 20) appSwitch: (null)
EngineDriver:EngineDriver() If this prints, the static initializer is running.
EngineDriver:Dangerous() Now attempting something dangerous!
Unhandled Exception: System.TypeInitializationException: An exception was
thrown by the type initializer for EngineDriver --->
System.Configuration.ConfigurationErrorsException: Error Initializing the
configuration system. ---> System.NullReferenceException: Object reference not
set to an instance of an object
at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal
(ConfigurationUserLevel userLevel, System.Reflection.Assembly calling_assembly,
System.String exePath) [0x00000]
at System.Configuration.ClientConfigurationSystem.get_Configuration ()
[0x00000]
--- End of inner exception stack trace ---
at System.Configuration.ClientConfigurationSystem.get_Configuration ()
[0x00000]
at
System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection
(System.String configKey) [0x00000]
at System.Configuration.ConfigurationManager.GetSection (System.String
sectionName) [0x00000]
at System.Configuration.ConfigurationSettings.GetConfig (System.String
sectionName) [0x00000]
at System.Diagnostics.DiagnosticsConfiguration.get_Settings () [0x00000]
at System.Diagnostics.Switch.GetConfigFileSetting () [0x00000]
at System.Diagnostics.Switch.get_SwitchSetting () [0x00000]
at System.Diagnostics.TraceSwitch.get_Level () [0x00000]
at EngineDriver.Dangerous () [0x00000]
at EngineDriver..cctor () [0x00000]
--- End of inner exception stack trace ---
make: *** [doit] Error 1
lfo at aztlan:~$ mono --version
Mono JIT compiler version 2.0 (tarball)
Copyright (C) 2002-2008 Novell, Inc and Contributors. www.mono-project.com
TLS: normal
GC: Included Boehm (with typed GC)
SIGSEGV: altstack
Notifications: epoll
Architecture: x86
Disabled: none
lfo at aztlan:~$
In Mono 1.2.6:
[lfo at megaro MonoTest]$ make
g++ -g -o engine `pkg-config --cflags mono` engine.cc `pkg-config --libs mono`
gmcs -target:library -r:System.Configuration.dll driver.cs
driver.cs(37,17): warning CS0169: The private method `EngineDriver.Invoke()' is
never used
driver.cs(12,19): warning CS0414: The private field `EngineDriver.confFile' is
assigned but its value is never used
driver.cs(13,19): warning CS0414: The private field `EngineDriver.appName' is
assigned but its value is never used
driver.cs(14,21): warning CS0414: The private field `EngineDriver.eAssem' is
assigned but its value is never used
driver.cs(15,21): warning CS0414: The private field `EngineDriver.cAssem' is
assigned but its value is never used
driver.cs(16,19): warning CS0414: The private field `EngineDriver.sillyString'
is assigned but its value is never used
Compilation succeeded - 6 warning(s)
first argument is location of mono root, second is the path to the dll
/engine /usr/local `pwd`/driver.dll
mono_jit_init()
mono_domain_assembly_open
mono_class_from_name()
mono_class_describe_statics(m_driverClass); // Before Invoke
At 0x2aaaab0d0ed0 (ofs: 0) confFile: (null)
At 0x2aaaab0d0ed8 (ofs: 8) appName: (null)
At 0x2aaaab0d0ee0 (ofs: 16) eAssem: (null)
At 0x2aaaab0d0ee8 (ofs: 24) cAssem: (null)
At 0x2aaaab0d0ef0 (ofs: 32) sillyString: (null)
At 0x2aaaab0d0ef8 (ofs: 40) appSwitch: (null)
EngineDriver:EngineDriver() If this prints, the static initializer is running.
EngineDriver:Dangerous() Now attempting something dangerous!
Trace switch mySwitch configured as Off
EngineDriver:Invoke() If this prints, the dynamic method invocation is running.
EngineDriver:Dangerous() Now attempting something dangerous!
Trace switch mySwitch configured as Off
mono_class_describe_statics(m_driverClass); // After Invoke
At 0x2aaaab0d0ed0 (ofs: 0) confFile: (null)
At 0x2aaaab0d0ed8 (ofs: 8) appName: String at 0x2aaaab0def60, length: 10,
'driver.dll'
At 0x2aaaab0d0ee0 (ofs: 16) eAssem: (null)
At 0x2aaaab0d0ee8 (ofs: 24) cAssem: System.Reflection.Assembly object at
0x2aaaab0d8de0 (klass: 0x65aca8)
At 0x2aaaab0d0ef0 (ofs: 32) sillyString: String at 0x2aaaab0def90, length: 8,
'Que mal!'
At 0x2aaaab0d0ef8 (ofs: 40) appSwitch: System.Diagnostics.TraceSwitch object at
0x2aaaab0e1fc0 (klass: 0x680410)
[lfo at megaro MonoTest]$ mono --version
Mono JIT compiler version 1.2.6 (tarball)
Copyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com
TLS: normal
GC: Included Boehm (with typed GC)
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
[lfo at megaro MonoTest]$ mono --version
Mono JIT compiler version 1.2.6 (tarball)
Copyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com
TLS: normal
GC: Included Boehm (with typed GC)
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
[lfo at megaro MonoTest]$ mono --version
Mono JIT compiler version 1.2.6 (tarball)
Copyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com
TLS: normal
GC: Included Boehm (with typed GC)
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
[lfo at megaro MonoTest]$
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list