Bugzilla – Bug 655139
Segmentation fault when executing .netZ packed app
Last modified: 2011-06-02 18:01:07 UTC
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.44 Safari/534.7 Hi, First of all: .netz is an executable packer, which uses only MSIL code. No native code. (http://madebits.com/netz/) I wrote a plugin for it which encrypts the app, instead of compressing it. It works fine under windows, but under OS X I get a segfault. I compressed/encrypted this EXE with a modified .netz under OS X, and if required, I'll send my modified .netz too. (I only added a reference to System.XML, so my plugin will work) Attached is the compressed/encrypted EXE file. Reproducible: Always Steps to Reproduce: 1. Download my prepared EXE 2. Run it Actual Results: see http://pastebin.com/FV7YuBva . Expected Results: The application should output: Hello I'm using Mac OS X 10.6.5, with latest Mono. I'm using latest .netz, compiled from source, with listed modifications.
Here's my packed exe: http://www.filesonic.com/file/33887747/module.exe (sorry, it's filesonic... My hosting doesn't handle .EXE files properly :-( )
It has the same behavior under Linux. (centos 5.4, x86) Mono JIT compiler version 1.2.4 (tarball) Copyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com TLS: __thread GC: Included Boehm (with typed GC) SIGSEGV: normal Architecture: x86 Disabled: none -Y
This looks like a stack overflow with the following stack trace: <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< at (wrapper runtime-invoke) <Module>.runtime_invoke_int_object (object,intptr,intptr,intptr) <IL 0x0005c, 0xffffffff> at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod*,object,object[],System.Exception&) <IL 0x0001c, 0xffffffff> at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x000d0] in /home/zovarga/git/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:226 at System.Reflection.MethodBase.Invoke (object,object[]) [0x00000] in /home/zovarga/git/mono/mcs/class/corlib/System.Reflection/MethodBase.cs:96 at netz.NetzStarter.InvokeApp (System.Reflection.Assembly,string[]) <IL 0x0002a, 0x000a3> at netz.NetzStarter.StartApp (string[]) <IL 0x00025, 0x00047> at netz.NetzStarter.Main (string[]) <IL 0x0001e, 0x0009b> at (wrapper runtime-invoke) <Module>.runtime_invoke_int_object (object,intptr,intptr,intptr) <IL 0x0005c, 0xffffffff> at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod*,object,object[],System.Exception&) <IL 0x0001c, 0xffffffff> at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x000d0] in /home/zovarga/git/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:226 at System.Reflection.MethodBase.Invoke (object,object[]) [0x00000] in /home/zovarga/git/mono/mcs/class/corlib/System.Reflection/MethodBase.cs:96 at netz.NetzStarter.InvokeApp (System.Reflection.Assembly,string[]) <IL 0x0002a, 0x000a3> at netz.NetzStarter.StartApp (string[]) <IL 0x00025, 0x00047> at netz.NetzStarter.Main (string[]) <IL 0x0001e, 0x0009b> at (wrapper runtime-invoke) <Module>.runtime_invoke_int_object (object,intptr,intptr,intptr) <IL 0x0005c, 0xffffffff> at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod*,object,object[],System.Exception&) <IL 0x0001c, 0xffffffff> at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x000d0] in /home/zovarga/git/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:226 at System.Reflection.MethodBase.Invoke (object,object[]) [0x00000] in /home/zovarga/git/mono/mcs/class/corlib/System.Reflection/MethodBase.cs:96 at netz.NetzStarter.InvokeApp (System.Reflection.Assembly,string[]) <IL 0x0002a, 0x000a3> at netz.NetzStarter.StartApp (string[]) <IL 0x00025, 0x00047> at netz.NetzStarter.Main (string[]) <IL 0x0001e, 0x0009b> at (wrapper runtime-invoke) <Module>.runtime_invoke_int_object (object,intptr,intptr,intptr) <IL 0x0005c, 0xffffffff> at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod*,object,object[],System.Exception&) <IL 0x0001c, 0xffffffff> at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x000d0] in /home/zovarga/git/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:226 at System.Reflection.MethodBase.Invoke (object,object[]) [0x00000] in /home/zovarga/git/mono/mcs/class/corlib/System.Reflection/MethodBase.cs:96 at netz.NetzStarter.InvokeApp (System.Reflection.Assembly,string[]) <IL 0x0002a, 0x000a3> at netz.NetzStarter.StartApp (string[]) <IL 0x00025, 0x00047> at netz.NetzStarter.Main (string[]) <IL 0x0001e, 0x0009b> at (wrapper runtime-invoke) <Module>.runtime_invoke_int_object (object,intptr,intptr,intptr) <IL 0x0005c, 0xffffffff> at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod*,object,object[],System.Exception&) <IL 0x0001c, 0xffffffff> at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x000d0] in /home/zovarga/git/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:226 at System.Reflection.MethodBase.Invoke (object,object[]) [0x00000] in /home/zovarga/git/mono/mcs/class/corlib/System.Reflection/MethodBase.cs:96 at netz.NetzStarter.InvokeApp (System.Reflection.Assembly,string[]) <IL 0x0002a, 0x000a3> at netz.NetzStarter.StartApp (string[]) <IL 0x00025, 0x00047> at netz.NetzStarter.Main (string[]) <IL 0x0001e, 0x0009b> at (wrapper runtime-invoke) <Module>.runtime_invoke_int_object (object,intptr,intptr,intptr) <IL 0x0005c, 0xffffffff> at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod*,object,object[],System.Exception&) <IL 0x0001c, 0xffffffff> at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x000d0] in /home/zovarga/git/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:226 at System.Reflection.MethodBase.Invoke (object,object[]) [0x00000] in /home/zovarga/git/mono/mcs/class/corlib/System.Reflection/MethodBase.cs:96 at netz.NetzStarter.InvokeApp (System.Reflection.Assembly,string[]) <IL 0x0002a, 0x000a3> at netz.NetzStarter.StartApp (string[]) <IL 0x00025, 0x00047> at netz.NetzStarter.Main (string[]) <IL 0x0001e, 0x0009b> at (wrapper runtime-invoke) <Module>.runtime_invoke_int_object (object,intptr,intptr,intptr) <IL 0x0005c, 0xffffffff> at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod*,object,object[],System.Exception&) <IL 0x0001c, 0xffffffff> at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x000d0] in /home/zovarga/git/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:226 at System.Reflection.MethodBase.Invoke (object,object[]) [0x00000] in /home/zovarga/git/mono/mcs/class/corlib/System.Reflection/MethodBase.cs:96 at netz.NetzStarter.InvokeApp (System.Reflection.Assembly,string[]) <IL 0x0002a, 0x000a3> at netz.NetzStarter.StartApp (string[]) <IL 0x00025, 0x00047> at netz.NetzStarter.Main (string[]) <IL 0x0001e, 0x0009b> at (wrapper runtime-invoke) <Module>.runtime_invoke_int_object (object,intptr,intptr,intptr) <IL 0x0005c, 0xffffffff> at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod*,object,object[],System.Exception&) <IL 0x0001c, 0xffffffff> at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x000d0] in /home/zovarga/git/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:226 at System.Reflection.MethodBase.Invoke (object,object[]) [0x00000] in /home/zovarga/git/mono/mcs/class/corlib/System.Reflection/MethodBase.cs:96 at netz.NetzStarter.InvokeApp (System.Reflection.Assembly,string[]) <IL 0x0002a, 0x000a3> at netz.NetzStarter.StartApp (string[]) <IL 0x00025, 0x00047> at netz.NetzStarter.Main (string[]) <IL 0x0001e, 0x0009b> at (wrapper runtime-invoke) <Module>.runtime_invoke_int_object (object,intptr,intptr,intptr) <IL 0x0005c, 0xffffffff> at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod*,object,object[],System.Exception&) <IL 0x0001c, 0xffffffff> at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x000d0] in /home/zovarga/git/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:226 at System.Reflection.MethodBase.Invoke (object,object[]) [0x00000] in /home/zovarga/git/mono/mcs/class/corlib/System.Reflection/MethodBase.cs:96 at netz.NetzStarter.InvokeApp (System.Reflection.Assembly,string[]) <IL 0x0002a, 0x000a3> at netz.NetzStarter.StartApp (string[]) <IL 0x00025, 0x00047> at netz.NetzStarter.Main (string[]) <IL 0x0001e, 0x0009b> at (wrapper runtime-invoke) <Module>.runtime_invoke_int_object (object,intptr,intptr,intptr) <IL 0x0005c, 0xffffffff> at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod*,object,object[],System.Exception&) <IL 0x0001c, 0xffffffff> at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x000d0] in /home/zovarga/git/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:226 at System.Reflection.MethodBase.Invoke (object,object[]) [0x00000] in /home/zovarga/git/mono/mcs/class/corlib/System.Reflection/MethodBase.cs:96 at netz.NetzStarter.InvokeApp (System.Reflection.Assembly,string[]) <IL 0x0002a, 0x000a3> at netz.NetzStarter.StartApp (string[]) <IL 0x00025, 0x00047> at netz.NetzStarter.Main (string[]) <IL 0x0001e, 0x0009b> at (wrapper runtime-invoke) <Module>.runtime_invoke_int_object (object,intptr,intptr,intptr) <IL 0x0005c, 0xffffffff> at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod*,object,object[],System.Exception&) <IL 0x0001c, 0xffffffff> at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x000d0] in /home/zovarga/git/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:226 at System.Reflection.MethodBase.Invoke (object,object[]) [0x00000] in /home/zovarga/git/mono/mcs/class/corlib/System.Reflection/MethodBase.cs:96 at netz.NetzStarter.InvokeApp (System.Reflection.Assembly,string[]) <IL 0x0002a, 0x000a3> at netz.NetzStarter.StartApp (string[]) <IL 0x00025, 0x00047> at netz.NetzStarter.Main (string[]) <IL 0x0001e, 0x0009b> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
So the problem is that the packed assembly is also called 'module', so Assembly.Load(byte[]) returns the main assembly, not the packed one, leading to the infinite recursion above.
Hi, Thank you for your help. I still got a few questions: * How did you manage to get that stacktrace? * Why does it work on MS.net, and not under Mono? Is mono stricter following the standard or something? -y
Here's another packed app: http://yvansoftware.be/HelloWorld.zip This time, it is called "HelloWorld", and not "Module". Or am I wrong here?
>>* Why does it work on MS.net, and not under Mono? Is mono stricter following the standard or something? This is still a bug in mono.
So basically, I found the following: * If I load an assembly with the same name, and call the entry point, the executing assembly is loaded, instead of the loaded assembly. * If I "fix" .netz to output the assembly in another name, it works :-). Changing the output name to "packed_" + assemblyName solved the problem. Do you need a working PE file, generated by .netz under mono/os x? -y