Bug 47424 - ARM64 issue with lock on Dictionary causes KeyNotFoundException
Summary: ARM64 issue with lock on Dictionary causes KeyNotFoundException
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: JIT (show other bugs)
Version: master
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-11-18 21:29 UTC by Andi McClure
Modified: 2018-01-18 22:38 UTC (History)
5 users (show)

Tags:
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:
Status:
RESOLVED FIXED

Description Andi McClure 2016-11-18 21:29:41 UTC
This seems to be a new error but has occurred six times in the last week. So far it occurs on ARM64 *ONLY*

The test MonoTests.Remoting.RemotingServicesTest.GetRealProxy fails with a managed exception and this stack trace:

                                                MESSAGE:
                                                System.Collections.Generic.KeyNotFoundException : The given key was not present in the dictionary.
                                                +++++++++++++++++++
                                                STACK TRACE:
                                                  at System.ThrowHelper.ThrowKeyNotFoundException () [0x00000] in /media/ssd/jenkins/workspace/test-mono-mainline-linux/label/debian-8-arm64/mcs/class/referencesource/mscorlib/system/throwhelper.cs:68 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) [0x00021] in <90234c02397e4bbe9ce0c6143919be6a>:0 
  at System.Net.Sockets.SafeSocketHandle.ReleaseHandle () [0x00085] in /media/ssd/jenkins/workspace/test-mono-mainline-linux/label/debian-8-arm64/mcs/class/System/System.Net.Sockets/SafeSocketHandle.cs:63 
  at System.Runtime.InteropServices.SafeHandle.DangerousReleaseInternal (System.Boolean dispose) [0x000d3] in /media/ssd/jenkins/workspace/test-mono-mainline-linux/label/debian-8-arm64/mcs/class/corlib/System.Runtime.InteropServices/SafeHandle.cs:227 
  at System.Runtime.InteropServices.SafeHandle.InternalDispose () [0x00011] in /media/ssd/jenkins/workspace/test-mono-mainline-linux/label/debian-8-arm64/mcs/class/corlib/System.Runtime.InteropServices/SafeHandle.cs:156 
  at System.Runtime.InteropServices.SafeHandle.Dispose (System.Boolean disposing) [0x00006] in /media/ssd/jenkins/workspace/test-mono-mainline-linux/label/debian-8-arm64/mcs/class/referencesource/mscorlib/system/runtime/interopservices/safehandle.cs:260 
  at System.Runtime.InteropServices.SafeHandle.Dispose () [0x00000] in /media/ssd/jenkins/workspace/test-mono-mainline-linux/label/debian-8-arm64/mcs/class/referencesource/mscorlib/system/runtime/interopservices/safehandle.cs:252 
  at System.Net.Sockets.Socket.Dispose (System.Boolean disposing) [0x00047] in /media/ssd/jenkins/workspace/test-mono-mainline-linux/label/debian-8-arm64/mcs/class/System/System.Net.Sockets/Socket.cs:2591 
  at System.Net.Sockets.Socket.Dispose () [0x00000] in /media/ssd/jenkins/workspace/test-mono-mainline-linux/label/debian-8-arm64/mcs/class/referencesource/System/net/System/Net/Sockets/Socket.cs:6396 
[snip]

Examples:
https://jenkins.mono-project.com/job/test-mono-mainline-linux/label=debian-8-arm64/1228/testReport/(root)/RemotingServicesTest/GetRealProxy/
https://jenkins.mono-project.com/job/test-mono-mainline-linux/label=debian-8-arm64/1201/testReport/(root)/RemotingServicesTest/GetRealProxy/
https://jenkins.mono-project.com/job/test-mono-mainline-linux/label=debian-8-arm64/1219/testReport/(root)/RemotingServicesTest/GetRealProxy/
Comment 1 Andi McClure 2016-11-18 22:10:44 UTC
Possibly related to #47433
Comment 4 Zoltan Varga 2016-12-01 20:08:19 UTC
This is caused by some kind of thread abort problem, the code looks like this:

			try {
				safeHandle.RegisterForBlockingSyscall ();
				var ret = Accept_internal (safeHandle.DangerousGetHandle (), out error, blocking);
				return new SafeSocketHandle (ret, true);
			} finally {
				safeHandle.UnRegisterForBlockingSyscall ();
			}

Register is called, but UnRegister is not, which causes the exception in ReleaseHandle () later.
Comment 5 Ludovic Henry 2018-01-18 22:38:39 UTC
The Thread.Abort mechanism was largely fixed, and there is no more signs of MonoTests.Remoting.RemotingServicesTest.GetRealProxy failing on CI.