Bug 4469 - SIGSEGV during debugging
Summary: SIGSEGV during debugging
Alias: None
Product: Runtime
Classification: Mono
Component: Debugger ()
Version: 5.0 (2017-02)
Hardware: PC Linux
: --- normal
Target Milestone: Future Cycle (TBD)
Assignee: Zoltan Varga
Depends on:
Reported: 2012-04-16 13:48 UTC by Marek Safar
Modified: 2017-07-11 23:01 UTC (History)
5 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 Marek Safar 2012-04-16 13:48:56 UTC

Native stacktrace:

	/home/marek/mono/bin/mono() [0x498447]
	/home/marek/mono/bin/mono() [0x4ec48f]
	/home/marek/mono/bin/mono() [0x419959]
	/lib/x86_64-linux-gnu/libpthread.so.0(+0xfc60) [0x2ab347d5cc60]
	/home/marek/mono/bin/mono() [0x4b9a2a]
	/home/marek/mono/bin/mono() [0x4b9fb2]
	/home/marek/mono/bin/mono() [0x4bad79]
	/home/marek/mono/bin/mono() [0x4c23d9]
	/home/marek/mono/bin/mono() [0x5be143]
	/home/marek/mono/bin/mono() [0x5cf2f9]
	/home/marek/mono/bin/mono() [0x5e9219]
	/lib/x86_64-linux-gnu/libpthread.so.0(+0x6d8c) [0x2ab347d53d8c]
	/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x2ab348051c2d]

Debug info from gdb:

Could not attach to process.  If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user.  For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.

Got a SIGSEGV 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 Marek Safar 2012-04-16 13:49:40 UTC
using System;
using System.Threading;
using System.Threading.Tasks;

class MyContext : SynchronizationContext
	public int Started;
	public int Completed;
	public int PostCounter;
	public int SendCounter;
	ManualResetEvent mre;
	public MyContext (ManualResetEvent mre)
		this.mre = mre;

	public override void OperationStarted ()
		base.OperationStarted ();

	public override void OperationCompleted ()
		base.OperationCompleted ();

	public override void Post (SendOrPostCallback d, object state)
		mre.Set ();	// Set a breakpoint here and hit F5 few times
		base.Post (d, state);

	public override void Send (SendOrPostCallback d, object state)
		base.Send (d, state);

public class TestPostContext
	static async Task<int> Test ()
		return await Task.Factory.StartNew (() => 1);

	public static int Main ()
		while (true) {
		var mre = new ManualResetEvent (false);
		var context = new MyContext (mre);
		try {
			SynchronizationContext.SetSynchronizationContext (context);
			var t = Test ();
			if (!t.Wait (3000))
				return 3;
			if (!mre.WaitOne (10000))
				return 2;
		} finally {
			SynchronizationContext.SetSynchronizationContext (null);

		if (context.Started != 0 || context.Completed != 0 || context.SendCounter != 0)
			return 1;

		if (context.PostCounter != 1)
			return 4;

		Console.WriteLine ("ok");
		return 0;
Comment 2 Zoltan Varga 2012-05-02 20:05:31 UTC
Can you test whenever this was fixed by the fix for #4737 ?
Comment 3 Ludovic Henry 2017-07-07 18:40:20 UTC
When running sample provided at https://bugzilla.xamarin.com/show_bug.cgi?id=4469#c1 I get an exit code of 2. Marek, is it the expected behaviour?
Comment 4 Rodrigo Kumpera 2017-07-11 23:01:48 UTC
Dotnet returns 2.