Bug 43191 - Mono crashes when debugging (unknown thread handle)
Summary: Mono crashes when debugging (unknown thread handle)
Alias: None
Product: Runtime
Classification: Mono
Component: Debugger ()
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Zoltan Varga
Depends on:
Reported: 2016-08-09 12:55 UTC by Dylan Borg
Modified: 2016-08-27 08:05 UTC (History)
3 users (show)

Is this bug a regression?: Yes
Last known good build: 18b834028e352707d0c79b7a3e363130b809f546

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Dylan Borg 2016-08-09 12:55:09 UTC
When using VSCode to debug an application running on mono I get the following at then end of execution:

unknown thread handle 0x1

Native stacktrace:

	mono() [0x4b32cf]
	/lib/x86_64-linux-gnu/libpthread.so.0(+0x113d0) [0x7fc02c7123d0]
	/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38) [0x7fc02c157418]
	/lib/x86_64-linux-gnu/libc.so.6(abort+0x16a) [0x7fc02c15901a]
	mono() [0x671b4b]
	mono() [0x6718e5]
	mono() [0x6719c4]
	mono() [0x665c7a]
	mono(mono_thread_cleanup+0x11) [0x5a86c1]
	mono(mono_runtime_cleanup+0x13) [0x5c7623]
	mono() [0x42447f]
	mono(mono_main+0x1141) [0x4859d1]
	mono() [0x421ed8]
	/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7fc02c142830]
	mono(_start+0x29) [0x422269]

Debug info from gdb:

[New LWP 5099]
warning: File "/usr/local/bin/mono-sgen-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
To enable execution of this file, add
	add-auto-load-safe-path /usr/local/bin/mono-sgen-gdb.py
line to your configuration file "/home/dylan/.gdbinit".
To completely disable this security protection, add
	set auto-load safe-path /
line to your configuration file "/home/dylan/.gdbinit".
For more information about this security protection, see the
"Auto-loading safe path" section in the GDB manual.  E.g., run from the shell:
	info "(gdb)Auto-loading safe path"
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007fc02c711fbb in __waitpid (pid=pid@entry=5101, stat_loc=stat_loc@entry=0x7ffc91f247fc, options=options@entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:29
29	../sysdeps/unix/sysv/linux/waitpid.c: No such file or directory.
  Id   Target Id         Frame 
* 1    Thread 0x7fc02d220780 (LWP 5091) "Main" 0x00007fc02c711fbb in __waitpid (pid=pid@entry=5101, stat_loc=stat_loc@entry=0x7ffc91f247fc, options=options@entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:29
  2    Thread 0x7fc029a5d700 (LWP 5099) "Debugger agent" 0x00007fc02c7118bf in __libc_recv (fd=fd@entry=4, buf=buf@entry=0x7fc029a5cd20, n=n@entry=11, flags=flags@entry=0) at ../sysdeps/unix/sysv/linux/x86_64/recv.c:28

Thread 2 (Thread 0x7fc029a5d700 (LWP 5099)):
#0  0x00007fc02c7118bf in __libc_recv (fd=fd@entry=4, buf=buf@entry=0x7fc029a5cd20, n=n@entry=11, flags=flags@entry=0) at ../sysdeps/unix/sysv/linux/x86_64/recv.c:28
#1  0x00000000004e1825 in recv (__flags=0, __n=11, __buf=0x7fc029a5cd20, __fd=4) at /usr/include/x86_64-linux-gnu/bits/socket2.h:44
#2  socket_transport_recv (buf=0x7fc029a5cd20, len=11) at debugger-agent.c:1130
#3  0x00000000004de0fd in transport_recv (len=11, buf=0x7fc029a5cd20) at debugger-agent.c:1536
#4  debugger_thread (arg=<optimised out>) at debugger-agent.c:9849
#5  0x00000000006663cf in inner_start_thread (arg=<optimised out>) at mono-threads-posix.c:156
#6  0x00007fc02c7086fa in start_thread (arg=0x7fc029a5d700) at pthread_create.c:333
#7  0x00007fc02c228b5d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 1 (Thread 0x7fc02d220780 (LWP 5091)):
#0  0x00007fc02c711fbb in __waitpid (pid=pid@entry=5101, stat_loc=stat_loc@entry=0x7ffc91f247fc, options=options@entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:29
#1  0x00000000004b33a6 in mono_handle_native_sigsegv (signal=<optimised out>, ctx=<optimised out>, info=<optimised out>) at mini-exceptions.c:2424
#2  <signal handler called>
#3  0x00007fc02c157418 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#4  0x00007fc02c15901a in __GI_abort () at abort.c:89
#5  0x0000000000671b4b in monoeg_log_default_handler (log_domain=0x0, log_level=G_LOG_LEVEL_ERROR, message=0xac41f0 "unknown thread handle 0x1", unused_data=0x0) at goutput.c:231
#6  0x00000000006718e5 in monoeg_g_logv (log_domain=0x0, log_level=G_LOG_LEVEL_ERROR, format=0x732326 "unknown thread handle %p", args=0x7ffc91f257c0) at goutput.c:111
#7  0x00000000006719c4 in monoeg_g_log (log_domain=0x0, log_level=G_LOG_LEVEL_ERROR, format=0x732326 "unknown thread handle %p") at goutput.c:121
#8  0x0000000000665c7a in mono_threads_platform_set_exited (info=0xa3a2d0) at mono-threads-posix.c:416
#9  0x00000000006649b5 in mono_thread_info_set_exited (info=<optimised out>) at mono-threads.c:1572
#10 0x00000000005a86c1 in mono_thread_cleanup () at threads.c:2952
#11 0x00000000005c7623 in mono_runtime_cleanup (domain=domain@entry=0xa51330) at appdomain.c:399
#12 0x000000000042447f in mini_cleanup (domain=0xa51330) at mini-runtime.c:4060
#13 0x00000000004859d1 in mono_main (argc=4, argv=<optimised out>) at driver.c:2152
#14 0x0000000000421ed8 in mono_main_with_options (argv=0x7ffc91f25c28, argc=4) at main.c:28
#15 main (argc=4, argv=0x7ffc91f25c28) at main.c:176

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.

bash: line 1:  5091 Aborted                 (core dumped) mono --debug --debugger-agent=transport=dt_socket,server=y,address= bin/Debug/net461/ubuntu.16.04-x64/clrtest.exe
Comment 1 Dylan Borg 2016-08-10 08:26:45 UTC
After some testing I can conclude that this was caused by a commit on Friday 5th August. Using commit '18b834028e352707d0c79b7a3e363130b809f546' does not yield this error.
Comment 2 Dylan Borg 2016-08-25 14:18:51 UTC
Has anyone seen this?
Comment 3 Zoltan Varga 2016-08-25 22:47:07 UTC
This is hopefully fixed now in master.
Comment 4 Dylan Borg 2016-08-27 07:55:11 UTC
Will test and report back.
Comment 5 Dylan Borg 2016-08-27 08:05:44 UTC
Yes it is fixed!