Bug 655139 - Segmentation fault when executing .netZ packed app
Summary: Segmentation fault when executing .netZ packed app
Status: NEW
Alias: None
Product: Mono: Runtime
Classification: Mono
Component: debug (show other bugs)
Version: 2.8.x
Hardware: x86-64 Mac OS X 10.6
: P5 - None : Critical
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-20 14:58 UTC by Yvan Janssens
Modified: 2011-06-02 18:01 UTC (History)
1 user (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yvan Janssens 2010-11-20 14:58:20 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.
Comment 1 Yvan Janssens 2010-11-20 15:00:41 UTC
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 :-( )
Comment 2 Yvan Janssens 2010-11-20 15:15:40 UTC
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
Comment 3 Forgotten User vxPDddArjq 2010-11-21 00:36:58 UTC
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>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Comment 4 Forgotten User vxPDddArjq 2010-11-21 00:52:53 UTC
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.
Comment 5 Yvan Janssens 2010-11-22 08:48:29 UTC
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
Comment 6 Yvan Janssens 2010-11-22 08:52:37 UTC
Here's another packed app:

http://yvansoftware.be/HelloWorld.zip

This time, it is called "HelloWorld", and not "Module". Or am I wrong here?
Comment 7 Forgotten User vxPDddArjq 2010-11-22 17:04:34 UTC
>>* 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.
Comment 8 Yvan Janssens 2010-11-22 17:35:15 UTC
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