I haven't tried any of the code, but looking over it here are a few thoughts. It appears the definition of sdp_list_t may be wrong. See http://sofia-sip.sourceforge.net/refdocs/sdp/sdp_8h-source.html . It seems to be missing the size field:
typedef struct sdp_list_s <http://sofia-sip.sourceforge.net/refdocs/sdp/structsdp__list__s.html> sdp_list_t <http://sofia-sip.sourceforge.net/refdocs/sdp/sdp_8h.html#aa3655f9abeaabb73ad45870f4b1eb22>; struct sdp_list_s <http://sofia-sip.sourceforge.net/refdocs/sdp/structsdp__list__s.html>{ int l_size <http://sofia-sip.sourceforge.net/refdocs/sdp/structsdp__list__s.html#06b47c31d917b16aca9942546c8646f2>; sdp_list_t <http://sofia-sip.sourceforge.net/refdocs/sdp/sdp_8h.html#aa3655f9abeaabb73ad45870f4b1eb22> *l_next <http://sofia-sip.sourceforge.net/refdocs/sdp/structsdp__list__s.html#cc02455e32c7a0132ae9c1e0a9637197>; sdp_text_t <http://sofia-sip.sourceforge.net/refdocs/sdp/sdp_8h.html#7d0c0b74d2456ed03bc985c3ccfb128b> *l_text <http://sofia-sip.sourceforge.net/refdocs/sdp/structsdp__list__s.html#f3bcab33331891add95041c41ef01d80>; }; Also, I am not sure how things will work out having a class as the return type of a pinvoke (sdp_list_append). It may marshal correctly, but then I *think* mono will try to free the memory of the unmanaged class. It might be better to return an IntPtr and marshal it yourself. Good luck. - Jonathan On 8/9/07, Andy Hume <[EMAIL PROTECTED]> wrote: > > Can someone try reproducing this for me. When I run the following program > it hangs _before_ entering the function doing a certain P/Invoke call. If I > comment out the sdp_list_append call it runs to completion. It doesn't > occur when run on the Windows mono.exe, but does in the Mono Suse vmx. It > needs BlueZ's libbluetooth. > > My best guess is that the jitter is getting stuck? There may well be > something wrong with the P/Invoke definitions :-,), but I'm reporting the > hang. > > > using System; > using System.Runtime.InteropServices; > > class Foo2 > { > static void Main() > { > Console.WriteLine("entering Main"); > fn1(); > } > static void fn1() > { > Console.WriteLine("entering fn1"); > fn2(); > } > static void fn2() > { > Console.WriteLine("entering fn2"); > fn3(); > } > > static void fn3() > { > Console.WriteLine("entering fn3"); > uuid_t svc_uuid = new uuid_t(); > NativeMethods.sdp_uuid16_create(svc_uuid, 0x0100); > // With this call in place, the programs hangs apparently > // before entering this function. 'kill -QUIT' shows > // Main->fn1->fn2->fn2<0xffffffff> > // Comment it out and the program runs to completion > // (likely producing a memory error when it does so). > /**/ > sdp_list_t search_list > = NativeMethods.sdp_list_append(null, svc_uuid); > //*/ > } > > [StructLayout(LayoutKind.Sequential)] > class uuid_t > { > public byte type; > public Guid uuid128; //? > } > > [StructLayout(LayoutKind.Sequential)] > class sdp_list_t > { > public sdp_list_t next; > public IntPtr data; > } > > class NativeMethods > { > const string BluetoothLibrary = "libbluetooth"; > > //sdp_list_t* sdp_list_append(sdp_list_t* list, void* d); > [DllImport(BluetoothLibrary)] > internal static extern sdp_list_t sdp_list_append(sdp_list_t list, > uuid_t d); > > //uuid_t* sdp_uuid16_create(uuid_t* uuid, uint16_t data); > [DllImport(BluetoothLibrary)] > internal static extern uuid_t sdp_uuid16_create(uuid_t uuid, Int16 > data); > > } > > }//class > > > The stack trace at hang is the following; note no fn3. > > [EMAIL PROTECTED]:~/Desktop/andy> mono --debug foo2.exe > entering fnMain > entering fn1 > entering fn2 > Full thread dump: > > "" tid=0x0xb7d74ae0 this=0x0x21e10: > at Foo2.fn2 () <0xffffffff> > at Foo2.fn2 () <0x00013> > at Foo2.fn1 () <0x00012> > at Foo2.Main () <0x00012> > at (wrapper runtime-invoke) > System.Object.runtime_invoke_void(object,intptr,intptr,intptr) <0xffffffff> > > _______________________________________________ > Mono-list maillist - [email protected] > http://lists.ximian.com/mailman/listinfo/mono-list >
_______________________________________________ Mono-list maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-list
