Bug 1499 - * Assertion at events.c:656, condition `thr_ret == 0' not met
Summary: * Assertion at events.c:656, condition `thr_ret == 0' not met
Alias: None
Product: Runtime
Classification: Mono
Component: JIT ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2011-10-14 12:07 UTC by Marek Safar
Modified: 2011-10-17 09:19 UTC (History)
2 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 2011-10-14 12:07:48 UTC
using System;
using System.Threading;

namespace TestAA
	class Program
		static void Main (string[] args)
			while (true) {
				ManualResetEvent mre = new ManualResetEvent (false);
				ThreadPool.QueueUserWorkItem (delegate {
					mre.WaitOne ();
					try {
						while (true) {
							mre.Set ();
					} catch (ObjectDisposedException) {

				ThreadPool.QueueUserWorkItem (delegate {
					mre.WaitOne ();
					Thread.Sleep (0);
					mre.Close ();

				mre.Set ();

				Thread.Sleep (3);

Crashes on most runs with both sgen (sometimes faster) and boehm

* Assertion at events.c:656, condition `thr_ret == 0' not met


  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) System.Threading.NativeEventCalls.SetEvent_internal (intptr) <0xffffffff>
  at System.Threading.EventWaitHandle.Set () <0x00023>
  at (wrapper remoting-invoke-with-check) System.Threading.EventWaitHandle.Set () <0xffffffff>
  at TestAA.Program/<Main>c__AnonStorey0.<>m__0 (object) <0x0002b>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object (object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

	mono-sgen() [0x494fe1]
	/lib/x86_64-linux-gnu/libpthread.so.0(+0xfc60) [0x7f1ae4ba8c60]
	/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x35) [0x7f1ae4838d05]
	/lib/x86_64-linux-gnu/libc.so.6(abort+0x186) [0x7f1ae483cab6]
	mono-sgen() [0x5f631b]
	mono-sgen() [0x5f6453]
	mono-sgen() [0x5d4cc5]

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 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 Zoltan Varga 2011-10-17 09:19:08 UTC
Fixed by adding locking to the relevant methods.