[Mono-list] Hang on JIT-ing fn with P/Invoke?

Andy Hume andyhume32 at yahoo.co.uk
Thu Aug 9 09:01:56 EDT 2007


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.

mono at mono:~/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>



More information about the Mono-list mailing list