Bug 16444 - Interrupting Mono in sdb while it's doing I/O causes io-layer assertion
Summary: Interrupting Mono in sdb while it's doing I/O causes io-layer assertion
Alias: None
Product: Runtime
Classification: Mono
Component: io-layer ()
Version: 3.2.x
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Rodrigo Kumpera
Depends on:
Reported: 2013-11-25 17:50 UTC by Alex Rønne Petersen
Modified: 2013-12-06 13:13 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

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 Alex Rønne Petersen 2013-11-25 17:50:03 UTC
alexrp@Zor ~/Projects/tests/cs $ sdb
Welcome to the Mono soft debugger (sdb 1.1.5071.32527)
Type 'help' for a list of commands or 'quit' to exit

(sdb) r test.exe
Inferior process '11234' ('test.exe') started
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello Wo^C* Assertion at wthreads.c:1221, condition `prev_handle == INTERRUPTION_REQUESTED_HANDLE' not met


  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) System.Threading.Monitor.try_enter_with_atomic_var (object,int,bool&) <IL 0x0000f, 0xffffffff>
  at System.Threading.Monitor.TryEnter (object,int,bool&) [0x00041] in /home/alexrp/Projects/mono/mcs/class/corlib/System.Threading/Monitor.cs:224
  at System.Threading.Monitor.Enter (object,bool&) [0x00000] in /home/alexrp/Projects/mono/mcs/class/corlib/System.Threading/Monitor.cs:198
  at (wrapper unknown) System.Threading.Monitor.FastMonitorEnterV4 (object,bool&) <IL 0x00059, 0xffffffff>
  at Mono.Debugger.Client.Log.Output (bool,string,string,object[]) [0x00022] in /home/alexrp/Projects/sdb/src/Log.cs:44
  at Mono.Debugger.Client.Log.Info (string,object[]) [0x00009] in /home/alexrp/Projects/sdb/src/Log.cs:60
  at Mono.Debugger.Client.CommandLine.ControlCHandler (int) [0x0001b] in /home/alexrp/Projects/sdb/src/CommandLine.cs:157
  at (wrapper native-to-managed) Mono.Debugger.Client.CommandLine.ControlCHandler (int) <IL 0x00021, 0xffffffff>
  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) System.Threading.WaitHandle.WaitOne_internal (System.Threading.WaitHandle,intptr,int,bool) <IL 0x0001c, 0xffffffff>
  at System.Threading.WaitHandle.WaitOne () [0x00015] in /home/alexrp/Projects/mono/mcs/class/corlib/System.Threading/WaitHandle.cs:357
  at Mono.Debugger.Client.CommandLine.Run (System.Version,bool,bool,System.Collections.Generic.IEnumerable`1<string>,System.Collections.Generic.IEnumerable`1<string>) [0x000d6] in /home/alexrp/Projects/sdb/src/CommandLine.cs:254
  at Mono.Debugger.Client.Program.Main (string[]) [0x00178] in /home/alexrp/Projects/sdb/src/Program.cs:100
  at (wrapper runtime-invoke) <Module>.runtime_invoke_int_object (object,intptr,intptr,intptr) <IL 0x0005c, 0xffffffff>

Native stacktrace:

	/opt/mono/bin/mono() [0x4ad63d]
	/lib/x86_64-linux-gnu/libpthread.so.0(+0xfcb0) [0x7f58884c4cb0]
	/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x35) [0x7f588812b425]
	/lib/x86_64-linux-gnu/libc.so.6(abort+0x17b) [0x7f588812eb8b]
	/opt/mono/bin/mono() [0x62f77d]
	/opt/mono/bin/mono() [0x62f8b6]
	/opt/mono/bin/mono() [0x61a95a]
	/opt/mono/bin/mono() [0x6050bf]
	/opt/mono/bin/mono() [0x617ede]
	/opt/mono/bin/mono() [0x5a568d]
	/opt/mono/bin/mono() [0x5a649b]

Debug info from gdb:

ptrace: Operation not permitted.
No threads.

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.

Comment 1 Alex Rønne Petersen 2013-11-25 17:52:01 UTC
Test case:

$ cat test.cs
class Program {
	static void Main () {
		while (true) {
			System.Console.WriteLine ("Hello World");
Comment 2 Zoltan Varga 2013-12-03 08:53:51 UTC
sdb executes managed code in signal handlers which is not safe to do since SIGINT is as async signal so the code handling it needs to be async safe.
Use Console.CancelKeyPress instead:
Comment 3 Zoltan Varga 2013-12-06 13:13:11 UTC