[Mono-list] System.CodeDom.Compiler.CSharpCodeProvider makes Crash

donggas90 donggas90 at gmail.com
Fri Oct 23 17:31:30 UTC 2015


System.CodeDom.Compiler.CSharpCodeProvider makes crash at mono_jit_cleanup().

Try below as a C# assembly.
        public static void Test()
        {
            string TestCode = @"using System;

namespace MyMono
{0}
    public class Program
    {0}
        public Program()
        {0}
        {1}

        public int DoSomething(int i)
        {0}
            {2}
            return i;
        {1}
    {1}
{1}";
            string code = string.Format(TestCode, "{", "}", "");
            CSharpCodeProvider compiler = new CSharpCodeProvider();
            CompilerParameters param = new CompilerParameters();
            param.GenerateExecutable = false;
            param.GenerateInMemory = false;
            param.OutputAssembly = "AnyName.dll";
            param.CompilerOptions = "/target:library";
            CompilerResults compileResults =
compiler.CompileAssemblyFromSource(param, code);
        }


and invoke it like below.
int main()
{
	mono_set_dirs(MONO_ROOT "\\lib", MONO_ROOT "\\etc");
	MonoDomain* lRootDomain = mono_jit_init("MyMono");

	MonoAssembly* lMonoAssembly = mono_domain_assembly_open(lRootDomain,
"Mono.dll");
	MonoImage* lMonoImage = mono_assembly_get_image(lMonoAssembly);
	MonoClass* lMonoClass = mono_class_from_name(lMonoImage, "Mono",
"Program");
	MonoMethod* lTestMethod = mono_class_get_method_from_name(lMonoClass,
"Test", 0);
	
	MonoObject* lException = nullptr;
	mono_runtime_invoke(lTestMethod, nullptr, nullptr, &lException);

	mono_jit_cleanup(lRootDomain);
	return 0;
}


Here is callstack.
 	ntdll.dll!_ZwClose at 4
()	Unknown
 	KernelBase.dll!_CloseHandle at 4
()	Unknown
 	kernel32.dll!_CloseHandleImplementation at 4
()	Unknown
 
mono-2.0.dll!ves_icall_System_Threading_InternalThread_Thread_free_internal(_MonoInternalThread
* this, void * thread) Line 1105	C
 	[External Code]	
 	[Frames below may be incorrect and/or missing]	
 	mono-2.0.dll!mono_gc_finalize_threadpool_threads() Line 237	C
 	mono-2.0.dll!mono_domain_finalize(_MonoDomain * domain, unsigned int
timeout) Line 402	C
 	mono-2.0.dll!mini_cleanup(_MonoDomain * domain) Line 7789	C

and output message is '0xC0000008: An invalid handle was specified.'

Sometimes the crash not occured. 
Typically, place a brakepoint at mono_jit_cleanup().
but placing a Sleep() has not effect.

I'm using 4.0.3 in Windows7 64bit.



--
View this message in context: http://mono.1490590.n4.nabble.com/System-CodeDom-Compiler-CSharpCodeProvider-makes-Crash-tp4666809.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list