Bug 24583 - Native SIGSEGV in Mono SIGQUIT signal handler when SIGQUIT received by native thread
Summary: Native SIGSEGV in Mono SIGQUIT signal handler when SIGQUIT received by native...
Alias: None
Product: Runtime
Classification: Mono
Component: Debugger ()
Version: 3.8.0
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Zoltan Varga
Depends on:
Reported: 2014-11-17 12:19 UTC by Tudor Simionescu
Modified: 2014-11-18 09:24 UTC (History)
2 users (show)

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

An archive containing a small example that reproduces the bug (1.62 KB, application/x-zip-compressed)
2014-11-17 12:19 UTC, Tudor Simionescu

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 Tudor Simionescu 2014-11-17 12:19:12 UTC
Created attachment 8770 [details]
An archive containing a small example that reproduces the bug

When a native thread not created by Mono intercepts a SIGQUIT issued to the Mono process, the Mono SIGQUIT signal handler gets a SIGSEGV in the following code:

static void 
mono_print_thread_dump_internal (void *sigctx, MonoContext *start_ctx) 
	MonoInternalThread *thread = mono_thread_internal_current (); 
 	MonoContext ctx; 
	GString* text = g_string_new (0); 
	char *name; 
#ifndef HOST_WIN32 
	char *wapi_desc; 
	GError *error = NULL; 

	if (thread->name) { //!thread is NULL (0x0) here, generating a SIGSEGV!

I am attaching some example code that reproduces the issue. The archive contains a script that runs make to build the native .so, then runs the interactive csharp interpreter with a .cs file that calls the native code to create some native threads. Finally, the script sends SIGQUIT to the newly created process (after a slight delay, to make sure everything is in the right state in the process), causing it to crash with SIGSEGV.

The example code I am attaching disables SIGQUIT handling on the main Mono thread and on the Mono finalizer thread. This makes the issue always reproducible, but is not required for the bug to manifest. In production code, we saw the bug manifesting especially during garbage collections - most likely because most Mono threads were suspended for garbage collection.
Comment 1 Zoltan Varga 2014-11-17 17:04:12 UTC
Fixed in mono master b3e8e1fa20e37e29deb390a6c1f11fdce0a915b0.
Comment 2 Tudor Simionescu 2014-11-18 09:24:46 UTC
Verified on head, it's working now. Thank you very much for the extremely quick response time!