Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
there
I have a C++ application developed by VC, compiled as DLL file. (The DLL is to access the physical Battery).I also have C# test console application, called the DLL file to get parameters of battery.
Both of them run on Windows smoothly, but when I try to run it on Ubuntu by mono.
There is always a exception when run it first time by mono, and just show on first time.
Does NOT show on by second ,third... time.
Command as below:
root@ubuntu:/home/user1/Desktop/CSharpTestConsoleAppFolder# mono ConsoleApplication1.exe
The exception as below:
mono: pthread_mutex_lock.c:312: __pthread_mutex_lock_full: Assertion `(- (e)) != 3 || !robust' failed.
Stacktrace:
at (wrapper managed-to-native) MonoLibUsb.MonoUsbApi.Close (intptr) <0xffffffff>
at MonoLibUsb.MonoUsbDeviceHandle.ReleaseHandle () <0x00063>
at System.Runtime.InteropServices.SafeHandle.Finalize () <0x0002f>
at (wrapper runtime-invoke) object.runtime_invoke_virtual_void__this__ (object,intptr,intptr,intptr) <0xffffffff>
Native stacktrace:
mono() [0x80e0124]
[0x66d410]
/lib/tls/i686/cmov/libc.so.6(abort+0x182) [0x169ab2]
/lib/tls/i686/cmov/libc.so.6(__assert_fail+0xf8) [0x15f748]
/lib/tls/i686/cmov/libpthread.so.0(+0x7e92) [0x8d3e92]
/usr/local/lib/libusb-1.0.so(libusb_close+0x40) [0xe531f0]
[0x6fff5c]
[0x5efc64]
[0x11ac78]
[0x11ac01]
mono() [0x812ac69]
mono() [0x82277c4]
mono() [0x812aec1]
mono() [0x81dcc96]
mono() [0x81ee9cf]
mono() [0x8224c23]
/lib/tls/i686/cmov/libpthread.so.0(+0x596e) [0x8d196e]
/lib/tls/i686/cmov/libc.so.6(clone+0x5e) [0x20f3fe]
Debug info from gdb:
Production_Date=
Serial_Number=
S12_FW_Verion=
S0_FW_Verion=
P001_System_Type=3
P002_Battery_Status=0
P003_Relative_State_Of_Charge=0%
P004_Run_Time_To_Empty=0
P005_Average_Time_To_Full=0
P006_Input_Current=0
P007_Output_Current=0
P008_Output_Voltage=0
P009_DC_DC_Voltage=0
P010_Battery_Voltage=0
P011_Enclosure_Temperature=0
P012_DC_DC_Temperature=0
P013_Battery_Capacity=0
P014_Pack_1_Plugged_In=1
P015_Pack_2_Plugged_In=1
P022_Pack_1_Temperature=0
P023_Pack_2_Temperature=0
P030_Pack_1_Device_Chemistry=3
P031_Pack_2_Device_Chemistry=3
P038_Pack_1_Design_Capacity=0
P039_Pack_2_Design_Capacity=0
P046_Pack_1_Design_Voltage=0
P047_Pack_2_Design_Voltage=0
P054_Pack_1_Serial_Number=0
P055_Pack_2_Serial_Number=0
P062_Pack_1_Remaining_Percentage=0
P063_Pack_2_Remaining_Percentage=0
P070_Pack_1_Remaining_Time=0
P071_Pack_2_Remaining_Time=0
P078_Pack_1_Remaining_Capacity=0
P079_Pack_2_Remaining_Capacity=0
P086_Pack_1_Full_Charge_Capacity=0
P087_Pack_2_Full_Charge_Capacity=0
P094_Pack_1_Current=0
P095_Pack_2_Current=0
P102_Pack_1_Voltage=0
P103_Pack_2_Voltage=0
P110_Pack_1_Cell_1_Voltage=0
P111_Pack_1_Cell_2_Voltage=0
P112_Pack_1_Cell_3_Voltage=0
P113_Pack_1_Cell_4_Voltage=0
P114_Pack_2_Cell_1_Voltage=0
P115_Pack_2_Cell_2_Voltage=0
P116_Pack_2_Cell_3_Voltage=0
P117_Pack_2_Cell_4_Voltage=0
P158_Pack_1_State=0
P159_Pack_2_State=0
P166_Charger_Temperature=0
P167_Fan_Less=0
Mono support loaded.
[Thread debugging using libthread_db enabled]
[New Thread 0xb6c46b70 (LWP 3123)]
[New Thread 0xb6d4bb70 (LWP 3116)]
[New Thread 0xb6d70b70 (LWP 3115)]
[New Thread 0xb6fcfb70 (LWP 3113)]
[New Thread 0xb72b9b70 (LWP 3107)]
0x0066d422 in __kernel_vsyscall ()
6 Thread 0xb72b9b70 (LWP 3107) 0x0066d422 in __kernel_vsyscall ()
5 Thread 0xb6fcfb70 (LWP 3113) 0x0066d422 in __kernel_vsyscall ()
4 Thread 0xb6d70b70 (LWP 3115) 0x0066d422 in __kernel_vsyscall ()
3 Thread 0xb6d4bb70 (LWP 3116) 0x0066d422 in __kernel_vsyscall ()
2 Thread 0xb6c46b70 (LWP 3123) 0x0066d422 in __kernel_vsyscall ()
* 1 Thread 0xb7700b40 (LWP 3106) 0x0066d422 in __kernel_vsyscall ()
Thread 6 (Thread 0xb72b9b70 (LWP 3107)):
#0 0x0066d422 in __kernel_vsyscall ()
#1 0x008d8f5b in read () from /lib/tls/i686/cmov/libpthread.so.0
#2 0x080e02ec in read (signal=6, ctx=0xb72b8abc) at /usr/include/bits/unistd.h:45
#3 mono_handle_native_sigsegv (signal=6, ctx=0xb72b8abc) at mini-exceptions.c:2207
#4 <signal handler called>
#5 0x0066d422 in __kernel_vsyscall ()
#6 0x00166681 in raise () from /lib/tls/i686/cmov/libc.so.6
#7 0x00169ab2 in abort () from /lib/tls/i686/cmov/libc.so.6
#8 0x0015f748 in __assert_fail () from /lib/tls/i686/cmov/libc.so.6
#9 0x008d3e92 in __pthread_mutex_lock_full () from /lib/tls/i686/cmov/libpthread.so.0
#10 0x00e531f0 in libusb_close (dev_handle=0xa0d1508) at core.c:1129
#11 0x006fff5c in ?? ()
#12 0x005efc64 in ?? ()
#13 0x0011ac78 in ?? ()
#14 0x0011ac01 in ?? ()
#15 0x0812ac69 in mono_gc_run_finalize (obj=0x922e8, data=0x0) at gc.c:224
#16 0x082277c4 in GC_invoke_finalizers () at finalize.c:787
#17 0x0812aec1 in finalizer_thread (unused=0x0) at gc.c:1093
#18 0x081dcc96 in start_wrapper_internal (data=0x9f9bdc8) at threads.c:783
#19 start_wrapper (data=0x9f9bdc8) at threads.c:831
#20 0x081ee9cf in thread_start_routine (args=0x9f8ac64) at wthreads.c:287
#21 0x08224c23 in GC_start_routine (arg=0x61fe0) at pthread_support.c:1468
#22 0x008d196e in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
#23 0x0020f3fe in clone () from /lib/tls/i686/cmov/libc.so.6
Thread 5 (Thread 0xb6fcfb70 (LWP 3113)):
#0 0x0066d422 in __kernel_vsyscall ()
#1 0x008d6015 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/tls/i686/cmov/libpthread.so.0
#2 0x08202f31 in _wapi_handle_timedwait_signal_handle (handle=0x411, timeout=0x0, alertable=1, poll=0) at handles.c:1654
#3 0x08202fa4 in _wapi_handle_wait_signal_handle (handle=0x411, alertable=1) at handles.c:1597
#4 0x081f2ee7 in WaitForSingleObjectEx (handle=0x411, timeout=4294967295, alertable=1) at wait.c:203
#5 0x081d9593 in ves_icall_System_Threading_WaitHandle_WaitOne_internal (this=0xce2e8, handle=0x411, ms=-1, exitContext=0) at threads.c:1664
#6 0x006ab5f4 in ?? ()
#7 0x006ab330 in ?? ()
#8 0x0084a2f1 in ?? ()
#9 0x00773d1c in ?? ()
#10 0x006acff8 in ?? ()
#11 0x006acf89 in ?? ()
#12 0x08062cf8 in mono_jit_runtime_invoke (method="System.Threading.ThreadStart:Invoke ()", obj=0xcf000, params=0xb6fcf2b8, exc=0x0) at mini.c:5764
#13 0x08187200 in mono_runtime_invoke (method="System.Threading.ThreadStart:Invoke ()", obj=0xcf000, params=0xb6fcf2b8, exc=0x0) at object.c:2755
#14 0x08187464 in mono_runtime_delegate_invoke (delegate=0xcf000, params=0xb6fcf2b8, exc=0x0) at object.c:3420
#15 0x081dcd67 in start_wrapper_internal (data=0xa101948) at threads.c:789
#16 start_wrapper (data=0xa101948) at threads.c:831
#17 0x081ee9cf in thread_start_routine (args=0x9f8b2c4) at wthreads.c:287
#18 0x08224c23 in GC_start_routine (arg=0xb1fe0) at pthread_support.c:1468
#19 0x008d196e in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
#20 0x0020f3fe in clone () from /lib/tls/i686/cmov/libc.so.6
Thread 4 (Thread 0xb6d70b70 (LWP 3115)):
#0 0x0066d422 in __kernel_vsyscall ()
#1 0x008d9736 in nanosleep () from /lib/tls/i686/cmov/libpthread.so.0
#2 0x081ed7b0 in SleepEx (ms=500, alertable=1) at wthreads.c:1027
#3 0x081d116f in monitor_thread (unused=0x0) at threadpool.c:777
#4 0x081dcc96 in start_wrapper_internal (data=0xa101948) at threads.c:783
#5 start_wrapper (data=0xa101948) at threads.c:831
#6 0x081ee9cf in thread_start_routine (args=0x9f8b3d4) at wthreads.c:287
#7 0x08224c23 in GC_start_routine (arg=0xb1fc0) at pthread_support.c:1468
#8 0x008d196e in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
#9 0x0020f3fe in clone () from /lib/tls/i686/cmov/libc.so.6
Thread 3 (Thread 0xb6d4bb70 (LWP 3116)):
#0 0x0066d422 in __kernel_vsyscall ()
#1 0x00206fc9 in ioctl () from /lib/tls/i686/cmov/libc.so.6
#2 0x00e58b6d in op_set_configuration (handle=0xa10d038, config=1) at os/linux_usbfs.c:1273
#3 0x00e522c8 in libusb_set_configuration (dev=0xa10d038, configuration=1) at core.c:1270
#4 0x0076b4fc in ?? ()
#5 0x0076b440 in ?? ()
#6 0x006a36f8 in ?? ()
#7 0x00856894 in ?? ()
#8 0x0084e0d8 in ?? ()
#9 0x0084d980 in ?? ()
#10 0x0084bb94 in ?? ()
#11 0x0084b7dc in ?? ()
#12 0x0069ecad in ?? ()
#13 0x08062cf8 in mono_jit_runtime_invoke (method="System.Threading.WaitCallback:Invoke ()", obj=0xcf070, params=0xb6d4b260, exc=0xb6d4b268) at mini.c:5764
#14 0x08187200 in mono_runtime_invoke (method="System.Threading.WaitCallback:Invoke ()", obj=0xcf070, params=0xb6d4b260, exc=0xb6d4b268) at object.c:2755
#15 0x08187464 in mono_runtime_delegate_invoke (delegate=0xcf070, params=0xb6d4b260, exc=0xb6d4b268) at object.c:3420
#16 0x081d365c in mono_async_invoke (data=0x55be0) at threadpool.c:626
#17 async_invoke_thread (data=0x55be0) at threadpool.c:1431
#18 0x081dcc96 in start_wrapper_internal (data=0xa101948) at threads.c:783
#19 start_wrapper (data=0xa101948) at threads.c:831
#20 0x081ee9cf in thread_start_routine (args=0x9f8b45c) at wthreads.c:287
#21 0x08224c23 in GC_start_routine (arg=0xb1fc0) at pthread_support.c:1468
#22 0x008d196e in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
#23 0x0020f3fe in clone () from /lib/tls/i686/cmov/libc.so.6
Thread 2 (Thread 0xb6c46b70 (LWP 3123)):
#0 0x0066d422 in __kernel_vsyscall ()
#1 0x00201536 in poll () from /lib/tls/i686/cmov/libc.so.6
#2 0x00e55688 in handle_events (ctx=<value optimized out>, tv=<value optimized out>) at io.c:1888
#3 0x00e55f17 in libusb_handle_events_timeout_completed (ctx=0xa108768, tv=0x38f74, completed=0x0) at io.c:2024
#4 0x00e5603c in libusb_handle_events_timeout (ctx=0xa108768, tv=0x38f74) at io.c:2078
#5 0x006ad2bc in ?? ()
#6 0x006ad0a8 in ?? ()
#7 0x006ad01e in ?? ()
#8 0x006acf89 in ?? ()
#9 0x08062cf8 in mono_jit_runtime_invoke (method="System.Threading.ThreadStart:Invoke ()", obj=0xb6b24ea8, params=0xb6c462b8, exc=0x0) at mini.c:5764
#10 0x08187200 in mono_runtime_invoke (method="System.Threading.ThreadStart:Invoke ()", obj=0xb6b24ea8, params=0xb6c462b8, exc=0x0) at object.c:2755
#11 0x08187464 in mono_runtime_delegate_invoke (delegate=0xb6b24ea8, params=0xb6c462b8, exc=0x0) at object.c:3420
#12 0x081dcd67 in start_wrapper_internal (data=0xa10a270) at threads.c:789
#13 start_wrapper (data=0xa10a270) at threads.c:831
#14 0x081ee9cf in thread_start_routine (args=0x9f8c22c) at wthreads.c:287
#15 0x08224c23 in GC_start_routine (arg=0x61b60) at pthread_support.c:1468
#16 0x008d196e in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
#17 0x0020f3fe in clone () from /lib/tls/i686/cmov/libc.so.6
Thread 1 (Thread 0xb7700b40 (LWP 3106)):
#0 0x0066d422 in __kernel_vsyscall ()
#1 0x008d9736 in nanosleep () from /lib/tls/i686/cmov/libpthread.so.0
#2 0x081ed7b0 in SleepEx (ms=6000, alertable=1) at wthreads.c:1027
#3 0x081de240 in ves_icall_System_Threading_Thread_Sleep_internal (ms=6000) at threads.c:1319
#4 0x0084a43c in ?? ()
#5 0x0084a3b8 in ?? ()
#6 0x0069fbd8 in ?? ()
#7 0x0069fcf7 in ?? ()
#8 0x08062cf8 in mono_jit_runtime_invoke (method="ConsoleApplication1.Program:Main ()", obj=0x0, params=0xbfb8f51c, exc=0x0) at mini.c:5764
#9 0x08187200 in mono_runtime_invoke (method="ConsoleApplication1.Program:Main ()", obj=0x0, params=0xbfb8f51c, exc=0x0) at object.c:2755
#10 0x0818aee6 in mono_runtime_exec_main (method="ConsoleApplication1.Program:Main ()", args=0x3be00, exc=0x0) at object.c:3938
#11 0x080bb445 in main_thread_handler (argc=2, argv=0xbfb8f704) at driver.c:1003
#12 mono_main (argc=2, argv=0xbfb8f704) at driver.c:1855
#13 0x0805944a in mono_main_with_options (argc=2, argv=0xbfb8f704) at main.c:66
#14 main (argc=2, argv=0xbfb8f704) at main.c:97
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
BTW, another Linux guy told me: It seems that the exception happen in Thread 1 #4 0x0084a43c in ?? () , "??()" is a function name, he told me need to add -g when compile, so ?? should be change to the function name,so I can find the reason. But the problem is I use Windows VC2012 to compile, I don't know how to add the parameter -g while compiling.
Additional Info: If I run "gdb mono" first, then run the test console application, there is no exception. It seems that there is message "Mono Support Loaded" either in the exception message or after run "gdb mono".
You probably mean Managed C++, which is why your application actually works. It may just be that you (or the mono runtime) are trying to free an uninitialized pointer, that may be initialized later - or on another thread, as your stacktrace indicates that there are many threads running (one of them appears stuck on an ioctl()).
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.