[Mono-bugs] [Bug 391858] New: Crash when calling C++ library using UnmanagedType.LPStr

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun May 18 15:52:45 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=391858


           Summary: Crash when calling C++ library using UnmanagedType.LPStr
           Product: Mono: Runtime
           Version: 1.9.0
          Platform: i386
        OS/Version: Kubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: interop
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: jimp02 at email.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


Created an attachment (id=216247)
 --> (https://bugzilla.novell.com/attachment.cgi?id=216247)
Test case for bug reprot

Calling an unmanaged C++ libary from a C# program, a return value of
UnmanagedType.LPStr causes a crash.
I think it is a runtime error but it could be the compiler.

A test case is attached. It contains a testlib.cpp program to be compiled as a
C++ shared library and a test.cs program to be compiled with C#.
A compiled C++ shared library for Linux i386, libtestlib.so, is also included.
A crash occurs when compiled with both version 1.1 (using mcs) and vesion 2.0
(using gmcs) of Mono .NET.
The program runs on Microsoft Vista when compiled with both version 2 and
version 3.5 of Microsoft .NET.

Following is the Microsoft output:

Void is OK
Int is OK = 2
Bool is OK = True
String is OK = string from library

When run on Linux it will be OK until the string test. The operating system is
Kubuntu using KDE version 3.5.9.
Following is the Mono output:

>mono test.exe
Void is OK
Int is OK = 2
Bool is OK = True
*** glibc detected *** mono: free(): invalid pointer: 0xb72c5688 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6[0xb7dc0a85]
/lib/tls/i686/cmov/libc.so.6(cfree+0x90)[0xb7dc44f0]
/usr/lib/libglib-2.0.so.0(g_free+0x31)[0xb7f248b1]
[0xb796ce56]
[0xb796cdb7]
[0xb79642b8]
[0xb79641c3]
mono(mono_runtime_exec_main+0xbb)[0x809c63b]
mono(mono_runtime_run_main+0x173)[0x809c933]
mono(mono_main+0x6a9)[0x805acd9]
mono[0x805a122]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0)[0xb7d6b450]
mono[0x805a091]
======= Memory map: ========
00010000-00081000 rwxp 00010000 00:00 0 
08048000-08204000 r-xp 00000000 08:05 676426     /usr/bin/mono
08204000-08206000 rwxp 001bb000 08:05 676426     /usr/bin/mono
08206000-082e8000 rwxp 08206000 00:00 0          [heap]
b7000000-b7021000 rwxp b7000000 00:00 0 
b7021000-b7100000 ---p b7021000 00:00 0 
b71c9000-b71d5000 r-xp 00000000 08:05 264172     /lib/libgcc_s.so.1
b71d5000-b71d6000 rwxp 0000b000 08:05 264172     /lib/libgcc_s.so.1
b71d6000-b72b9000 r-xp 00000000 08:05 672683     /usr/lib/libstdc++.so.6.0.10
b72b9000-b72bc000 r-xp 000e3000 08:05 672683     /usr/lib/libstdc++.so.6.0.10
b72bc000-b72be000 rwxp 000e6000 08:05 672683     /usr/lib/libstdc++.so.6.0.10
b72be000-b72c4000 rwxp b72be000 00:00 0 
b72c4000-b72c5000 r-xp 00000000 08:05 675018     /usr/lib/libtestlib.so
b72c5000-b72c6000 rwxp 00000000 08:05 675018     /usr/lib/libtestlib.so
b72da000-b72de000 rwxp b72da000 00:00 0 
b72de000-b72e7000 ---p b72de000 00:00 0 
b72e7000-b73e0000 rwxp b72e7000 00:00 0 
b73e0000-b73ff000 ---p b73e0000 00:00 0 
b73ff000-b7784000 rwxs 00000000 08:05 394992    
/home/jp/.wapi/shared_fileshare-ubuntu-Linux-i686-36-11-0
b7784000-b78bd000 rwxs 00000000 08:05 393465    
/home/jp/.wapi/shared_data-ubuntu-Linux-i686-312-11-0
b78bd000-b792a000 rwxp b78bd000 00:00 0 
b792a000-b7933000 r-xp 00000000 08:05 262177    
/lib/tls/i686/cmov/libnss_files-2.7.so
b7933000-b7935000 rwxp 00008000 08:05 262177    
/lib/tls/i686/cmov/libnss_files-2.7.so
b7935000-b793d000 r-xp 00000000 08:05 262179    
/lib/tls/i686/cmov/libnss_nis-2.7.so
b793d000-b793f000 rwxp 00007000 08:05 262179    
/lib/tls/i686/cmov/libnss_nis-2.7.so
b793f000-b7953000 r-xp 00000000 08:05 262174    
/lib/tls/i686/cmov/libnsl-2.7.so
b7953000-b7955000 rwxp 00013000 08:05 262174    
/lib/tls/i686/cmov/libnsl-2.7.so
b7955000-b7957000 rwxp b7955000 00:00 0 
b7957000-b795e000 r-xp 00000000 08:05 262175    
/lib/tls/i686/cmov/libnss_compat-2.7.so
b795e000-b7960000 rwxp 00006000 08:05 262175    
/lib/tls/i686/cmov/libnss_compat-2.7.so
b7960000-b7961000 ---p b7960000 00:00 0 
b7961000-b7974000 rwxp b7961000 00:00 0 
b7974000-b7bde000 r-xp 00000000 08:05 138077     /usr/lib/mono/2.0/mscorlib.dll
b7bde000-b7bdf000 r-xp 00000000 08:05 395044    
/home/jp/Projects/astylex/src-test/test.exe
b7bdf000-b7bf3000 rwxp b7bdf000 00:00 0 
b7bf3000-b7c32000 r-xp 00000000 08:05 705041    
/usr/lib/locale/en_US.utf8/LC_CTYPE
b7c32000-b7d13000 r-xp 00000000 08:05 708488    
/usr/lib/locale/en_US.utf8/LC_COLLATE
b7d13000-b7d14000 rwxp b7d13000 00:00 0 
b7d14000-b7d3a000 r-xp 00000000 08:05 677566     /usr/lib/libpcre.so.3.12.1
b7d3a000-b7d3b000 rwxp 00026000 08:05 677566     /usr/lib/libpcre.so.3.12.1
b7d3b000-b7d3c000 rwxp b7d3b000 00:00 0 
b7d3c000-b7d53000 r-xp 00000000 08:05 262206     /lib/libselinux.so.1
b7d53000-b7d55000 rwxp 00016000 08:05 262206     /lib/libselinux.so.1
b7d55000-b7e9e000 r-xp 00000000 08:05 262168     /lib/tls/i686/cmov/libc-2.7.so
b7e9e000-b7e9f000 r-xp 00149000 08:05 262168     /lib/tls/i686/cmov/libc-2.7.so
b7e9f000-b7ea1000 rwxp 0014a000 08:05 262168     /lib/tls/i686/cmov/libc-2.7.so
b7ea1000-b7ea4000 rwxp b7ea1000 00:00 0 
b7ea4000-b7ec7000 r-xp 00000000 08:05 262172     /lib/tls/i686/cmov/libm-2.7.so
b7ec7000-b7ec9000 rwxp 00023000 08:05 262172     /lib/tls/i686/cmov/libm-2.7.so
b7ec9000-b7edd000 r-xp 00000000 08:05 262182    
/lib/tls/i686/cmov/libpthread-2.7.so
b7edd000-b7edf000 rwxp 00013000 08:05 262182    
/lib/tls/i686/cmov/libpthread-2.7.so
b7edf000-b7ee1000 rwxp b7edf000 00:00 0 
b7ee1000-b7ee3000 r-xp 00000000 08:05 262171    
/lib/tls/i686/cmov/libdl-2.7.so
b7ee3000-b7ee5000 rwxp 00001000 08:05 262171    
/lib/tls/i686/cmov/libdl-2.7.so
b7ee5000-b7f95000 r-xp 00000000 08:05 683670    
/usr/lib/libglib-2.0.so.0.1600.3
b7f95000-b7f96000 rwxp 000b0000 08:05 683670    
/usr/lib/libglib-2.0.so.0.1600.3
b7f96000-b7f97000 rwxp b7f96000 00:00 0 
b7f97000-b7f9e000 r-xp 00000000 08:05 262184    
/lib/tls/i686/cmov/librt-2.7.so
b7f9e000-b7fa0000 rwxp 00006000 08:05 262184    
/lib/tls/i686/cmov/librt-2.7.so
b7fa0000-b7fa4000 r-xp 00000000 08:05 683673    
/usr/lib/libgthread-2.0.so.0.1600.3
b7fa4000-b7fa5000 rwxp 00003000 08:05 683673    
/usr/lib/libgthread-2.0.so.0.1600.3
b7fa8000-b7fa9000 r-xp 00000000 08:05 705198    
/usr/lib/locale/en_US.utf8/LC_NUMERIC
b7fa9000-b7faa000 r-xp 00000000 08:05 708469    
/usr/lib/locale/en_US.utf8/LC_TIME
b7faa000-b7fab000 r-xp 00000000 08:05 708526    
/usr/lib/locale/en_US.utf8/LC_MONETARY
b7fab000-b7fac000 r-xp 00000000 08:05 708557    
/usr/lib/locale/en_US.utf8/LC_MESSAGES/SYS_LC_MESSAGES
b7fac000-b7fad000 r-xp 00000000 08:05 708558    
/usr/lib/locale/en_US.utf8/LC_PAPER
b7fad000-b7fae000 r-xp 00000000 08:05 708559    
/usr/lib/locale/en_US.utf8/LC_NAME
b7fae000-b7faf000 r-xp 00000000 08:05 708560    
/usr/lib/locale/en_US.utf8/LC_ADDRESS
b7faf000-b7fb0000 r-xp 00000000 08:05 708561    
/usr/lib/locale/en_US.utf8/LC_TELEPHONE
b7fb0000-b7fb1000 r-xp 00000000 08:05 708562    
/usr/lib/locale/en_US.utf8/LC_MEASUREMENT
b7fb1000-b7fb8000 r-xs 00000000 08:05 672999    
/usr/lib/gconv/gconv-modules.cache
b7fb8000-b7fb9000 r-xp 00000000 08:05 708563    
/usr/lib/locale/en_US.utf8/LC_IDENTIFICATION
b7fb9000-b7fbb000 rwxp b7fb9000 00:00 0 
b7fbb000-b7fbc000 r-xp b7fbb000 00:00 0          [vdso]
b7fbc000-b7fd6000 r-xp 00000000 08:05 262385     /lib/ld-2.7.so
b7fd6000-b7fd8000 rwxp 00019000 08:05 262385     /lib/ld-2.7.so
bf50b000-bf513000 ---p bf50b000 00:00 0 
bfcf5000-bfd0a000 rwxp bffeb000 00:00 0          [stack]
Stacktrace:

  at (wrapper managed-to-native) System.Object.__icall_wrapper_g_free (intptr)
<0x00004>
  at (wrapper managed-to-native) System.Object.__icall_wrapper_g_free (intptr)
<0xffffffff>
  at (wrapper managed-to-native) Test.testLPStr () <0xffffffff>
  at Test.Main (string[]) <0x0008f>
  at (wrapper runtime-invoke) Test.runtime_invoke_void_string[]
(object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

        mono [0x816b1fa]
        [0xb7fbb440]
        /lib/tls/i686/cmov/libc.so.6(abort+0x101) [0xb7d81a01]
        /lib/tls/i686/cmov/libc.so.6 [0xb7db8b7c]
        /lib/tls/i686/cmov/libc.so.6 [0xb7dc0a85]
        /lib/tls/i686/cmov/libc.so.6(cfree+0x90) [0xb7dc44f0]
        /usr/lib/libglib-2.0.so.0(g_free+0x31) [0xb7f248b1]
        [0xb796ce56]
        [0xb796cdb7]
        [0xb79642b8]
        [0xb79641c3]
        mono(mono_runtime_exec_main+0xbb) [0x809c63b]
        mono(mono_runtime_run_main+0x173) [0x809c933]
        mono(mono_main+0x6a9) [0x805acd9]
        mono [0x805a122]
        /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0) [0xb7d6b450]
        mono [0x805a091]
>Exit code: 0 Signal: 9


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list