[ubuntu-mono] [Bug 122496] Re: mono always crashes on ppc

Alessandro Decina alessandro at nnva.org
Fri Jul 13 16:50:41 UTC 2007


The ndesk segfault is due to an inconsistency in how structs are passed
in pinvoke. On ppc structs are always passed by-address. This is how
GIOChannel is wrapped in ndesk-glib:

	struct IOChannel
	{
		const string GLIB = "libglib-2.0-0.dll";

                public IntPtr Handle;

		[DllImport(GLIB)]
			static extern IntPtr g_io_channel_unix_new (int fd);
		public IOChannel (int fd)
		{
			Handle = g_io_channel_unix_new (fd);
		}
[snip]

Then g_io_add_watch is defined as a pinvoke method:

[snip]
			[DllImport(GLIB)]
			protected static extern uint g_io_add_watch (IOChannel channel, IOCondition condition, IOFunc func, IntPtr user_data);
[snip]

The g_io_add_watch wrapper takes a IOChannel structure as its first argument. The real g_io_add_watch takes a GIOChannel * argument as first argument.
On x86 this works because IOChannel is passed by value, so the GIOChannel * pointer in the real g_io_add_watch gets the value of IOChannel::Handle which points to the right location.
On ppc IOChannel is passed by address, so the GIOChannel * pointer in the real g_io_add_watch gets *a pointer* to IOChannel::Handle.

setting PPC_PASS_STRUCTS_BY_VALUE to 1 in mono/mini/mini-ppc.h and
recompiling fixes the bug here. Anyway i don't know  why it is set to 0
by default and if changing it has any drawbacks.

-- 
mono always crashes on ppc
https://bugs.launchpad.net/bugs/122496
You received this bug notification because you are a member of MOTU Mono
Team, which is a bug contact for mono in ubuntu.




More information about the Ubuntu-mono mailing list