[Mono-list] Trouble Porting a C# Ogg, Vorbis, Theora wrapper to Mono
Miguel de Icaza
miguel at novell.com
Tue May 20 17:21:01 EDT 2008
My suggestion is to try Valgrind, your marshalling might be buggy in
some place and it just happens to trample on some memory on Linux that
you do not trample on Windows.
On Mon, 2008-05-19 at 22:14 +0100, Charles Mason wrote:
> Hi All,
>
> I am currently trying to port an open source wrapper I wrote for
> libogg, libvorbis and libtheora to mono. All of the above libraries
> are standard portable C libraries compiled as shared objects.
>
> I currently have a wrapper for each of the three libraries written in
> C#, which works correctly on windows. However when I try to use the
> same wrapper with mono and linux versions of same libraries I get a
> SIGSEGV error. Know the C libraries are identical as I have compiled
> them myself form the same code which works on windows.
>
> All of the marshaling my wrappers do is manual, using the Marshal
> class, except for a few single value types (int & doubles mostly). I
> assumed I was trying to free some unmanaged memory that was currently
> in use by the native library, so as I test I tried commenting out all
> references to Marshal.FreeHGlobal.This hasn't stopped the SIGSEGV
> error.
>
> The Managed Stack Trace mono creates seems to point to a different
> method every time. So I began to wonder if it was mono which actually
> triggered the SIGSEGV error. I updated from the standard Ubuntu
> packages to a third party one containing the latest release, the
> problem was unchanged.
>
> After installing the debug symbols for mono I manged to use gdb to do
> a back trace. I don't know much about the internals of mono but, from
> what I can tell it appears to be part of the mono garbage collector
> which is causing the SIGSEGV. I have included the back trace below.
>
> (gdb) mono_backtrace 40
> #0 0xb7fa9410 in __kernel_vsyscall ()
> #1 0xb7d6e085 in raise () from /lib/tls/i686/cmov/libc.so.6
> #2 0xb7d6fa01 in abort () from /lib/tls/i686/cmov/libc.so.6
> #3 0x08181782 in mono_handle_native_sigsegv (signal=11, ctx=0xb7b06d0c)
> at mini-exceptions.c:1080
> 1080 mini-exceptions.c: No such file or directory.
> in mini-exceptions.c
> #4 0x08080001 in mono_arch_handle_altstack_exception (sigctx=0xb7b06d0c,
> fault_addr=0x5, stack_ovf=0) at exceptions-x86.c:855
> 855 exceptions-x86.c: No such file or directory.
> in exceptions-x86.c
> #5 <signal handler called>
> #6 0x08142423 in GC_mark_from (mark_stack_top=0x20160, mark_stack=0x20000,
> mark_stack_limit=0x28000) at mark.c:724
> 724 mark.c: No such file or directory.
> in mark.c
> #7 0x081427ef in GC_mark_some (cold_gc_frame=0xbfc7bcac "") at mark.c:378
> 378 in mark.c
> #8 0x0813884b in GC_stopped_mark (stop_func=0x8137e30 <GC_never_stop_func>)
> at alloc.c:544
> 544 alloc.c: No such file or directory.
> in alloc.c
> #9 0x08138bc7 in GC_try_to_collect_inner (
> stop_func=0x8137e30 <GC_never_stop_func>) at alloc.c:386
> 386 in alloc.c
> #10 0x08138f3c in GC_collect_or_expand (needed_blocks=43, ignore_off_page=0)
> at alloc.c:1046
> ---Type <return> to continue, or q <return> to quit---
> 1046 in alloc.c
> #11 0x0819817a in GC_alloc_large (lw=43012, k=0, flags=0) at malloc.c:60
> 60 malloc.c: No such file or directory.
> in malloc.c
> #12 0x08198436 in GC_generic_malloc (lb=172048, k=0) at malloc.c:204
> 204 in malloc.c
> #13 0x08198663 in GC_malloc_atomic (lb=172048) at malloc.c:270
> 270 in malloc.c
> #14 0x080ae24f in mono_array_new_specific (vtable=0x8403878, n=86016)
> at object.c:3321
> 3321 object.c: No such file or directory.
> in object.c
> #15 0xb787fdca in (wrapper managed-to-native)
> System.Object:__icall_wrapper_mono_array_new_specific (intptr,int) +
> 0x2a (0xb787fda0 0xb787fdf0) [0x34f00 - AMPE Command Line Audio
> Player.exe]
> #16 0x08403878 in ?? ()
> #17 0x00015000 in ?? ()
> #18 0x08235d78 in ?? ()
> #19 0x0009df50 in ?? ()
> #20 0x00000000 in ?? ()
> Initial frame selected; you cannot go up.
>
> Does anyone have any suggestions on how I can find the cause of this
> problem? There can't be too many problems with my code as the same
> code runs on windows fine. Is there something particularly different
> about the way mono handles unmanaged memory. Is it possible to
> completely disable the garbage collector to see if that stops the
> SIGSEGV error. I know its not a viable solution but it would at least
> help narrow down the cause.
>
> Any help would be greatly appreciated on this.
>
> Charlie M
> _______________________________________________
> Mono-list maillist - Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
More information about the Mono-list
mailing list