Bug 51939 - SemaphoreFullException when stress testin socket server with SocketAsyncEventArgs
Summary: SemaphoreFullException when stress testin socket server with SocketAsyncEvent...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Ludovic Henry
URL:
Depends on:
Blocks:
 
Reported: 2017-01-29 17:29 UTC by apollo_maverick
Modified: 2017-03-03 13:41 UTC (History)
4 users (show)

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


Attachments
shot (163.63 KB, image/png)
2017-01-29 17:29 UTC, apollo_maverick
Details
testcase (19.86 KB, application/x-zip-compressed)
2017-01-30 20:19 UTC, apollo_maverick
Details


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 apollo_maverick 2017-01-29 17:29:57 UTC
Created attachment 19620 [details]
shot

Unhandled Exception:
System.Threading.SemaphoreFullException: Adding the specified count to the semaphore would
cause it to exceed its maximum count.
   at System.Threading.SemaphoreSlim.Release (System.Int32 releaseCount)
   at System.Threading.SemaphoreSlim.Release ()
   at System.Net.Sockets.SocketAsyncResult.Complete()

Mono master branch: git commit 9bee02a

Linux Ubuntu kernel 4.4.0-59-generic x86_64

It's OK stress running on the same box with MS.NET Core CLR and Fx.
Comment 1 apollo_maverick 2017-01-29 17:31:06 UTC
Mono master branch (-V shows 4.9.0): git commit 9bee02a
Comment 2 apollo_maverick 2017-01-30 20:19:07 UTC
Created attachment 19648 [details]
testcase

launch the app using mono,
run: wrk -c 1000 http://127.0.0.1:8000/
Comment 3 apollo_maverick 2017-01-30 20:48:49 UTC
sorry, you may use the port 80, or you can mod port in the .exe.config file.
Comment 4 Ludovic Henry 2017-02-08 21:46:18 UTC
When trying to run your testcase, I get the following exception:

> Unhandled Exception:
> System.TypeInitializationException: The type initializer for 'ConsoleApplication14.Program' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Error Initializing the configuration system. ---> > System.Configuration.ConfigurationErrorsException: Unrecognized configuration section <startup> (/Users/ludovic/Downloads/ConsoleApplication14/ConsoleApplication14.exe.config line 3)
>   at System.Configuration.ConfigInfo.ThrowException (System.String text, System.Xml.XmlReader reader) [0x00000] in /Users/ludovic/Xamarin/mono/mcs/class/System.Configuration/System.Configuration/ConfigInfo.cs:77
>   at System.Configuration.SectionGroupInfo.ReadContent (System.Xml.XmlReader reader, System.Configuration.Configuration config, System.Boolean overrideAllowed, System.Boolean root) [0x00127] in /Users/ludovic/Xamarin/mono/mcs/> class/System.Configuration/System.Configuration/SectionGroupInfo.cs:330
>   at System.Configuration.SectionGroupInfo.ReadRootData (System.Xml.XmlReader reader, System.Configuration.Configuration config, System.Boolean overrideAllowed) [0x00007] in /Users/ludovic/Xamarin/mono/mcs/class/> System.Configuration/System.Configuration/SectionGroupInfo.cs:273
>   at System.Configuration.Configuration.ReadConfigFile (System.Xml.XmlReader reader, System.String fileName) [0x000ce] in /Users/ludovic/Xamarin/mono/mcs/class/System.Configuration/System.Configuration/Configuration.cs:572
>   at System.Configuration.Configuration.Load () [0x00043] in /Users/ludovic/Xamarin/mono/mcs/class/System.Configuration/System.Configuration/Configuration.cs:532
>   at System.Configuration.Configuration.Init (System.Configuration.Internal.IConfigSystem system, System.String configPath, System.Configuration.Configuration parent) [0x0005d] in /Users/ludovic/Xamarin/mono/mcs/class/> System.Configuration/System.Configuration/Configuration.cs:138
>   at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00056] in /Users/ludovic/Xamarin/mono/mcs/class/System.Configuration/> System.Configuration/Configuration.cs:96
>   at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] hostInitConfigurationParams) [0x0000d] in /Users/ludovic/Xamarin/mono/mcs/class/System.Configuration/> System.Configuration/InternalConfigurationFactory.cs:41
>   at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal (System.Configuration.ConfigurationUserLevel userLevel, System.Reflection.Assembly calling_assembly, System.String exePath) [0x000ea] in /Users/> ludovic/Xamarin/mono/mcs/class/System.Configuration/System.Configuration/ConfigurationManager.cs:119
>   at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x0000e] in /Users/ludovic/Xamarin/mono/mcs/class/System.Configuration/System.Configuration/ClientConfigurationSystem.cs:49
>    --- End of inner exception stack trace ---
>   at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x0001f] in /Users/ludovic/Xamarin/mono/mcs/class/System.Configuration/System.Configuration/ClientConfigurationSystem.cs:52
>   at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in /Users/ludovic/Xamarin/mono/mcs/class/System.Configuration/> System.Configuration/ClientConfigurationSystem.cs:61
>   at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in /Users/ludovic/Xamarin/mono/mcs/class/System.Configuration/System.Configuration/ConfigurationManager.cs:159
>   at System.Configuration.ConfigurationManager.get_AppSettings () [0x00000] in /Users/ludovic/Xamarin/mono/mcs/class/System.Configuration/System.Configuration/ConfigurationManager.cs:173
>   at ZYSocket.Server.IPConfig.ReadString (System.String key) [0x00000] in <a9bdef00911d40c5ad2f9d2d1b43250c>:0
>   at ZYSocket.Server.IPConfig.ReadInt (System.String key) [0x00000] in <a9bdef00911d40c5ad2f9d2d1b43250c>:0
>   at ZYSocket.Server.ZYSocketSuper..ctor () [0x00006] in <a9bdef00911d40c5ad2f9d2d1b43250c>:0
>   at ConsoleApplication14.Program..cctor () [0x00000] in <6eaef944dbf342c2bc5048774db895be>:0
>    --- End of inner exception stack trace ---
Comment 5 apollo_maverick 2017-02-09 15:53:29 UTC
what's your mono -V version, what's your linux distribution? just download the testcase attachment and checked again with latest CI master branch build, same exception.
Comment 6 apollo_maverick 2017-02-09 15:56:05 UTC
the full exception message is:

Unhandled Exception:
System.Threading.SemaphoreFullException: Adding the specified count to the semaphore would cause it to exceed its maximum count.
  at System.Threading.SemaphoreSlim.Release (System.Int32 releaseCount) [0x0004c] in <d9b55d9a4bc046648dbe0b2040413b94>:0 
  at System.Threading.SemaphoreSlim.Release () [0x00000] in <d9b55d9a4bc046648dbe0b2040413b94>:0 
  at System.Net.Sockets.SocketAsyncResult.Complete () [0x000aa] in <9452bf5cef7942ad958da6bd6bb9647c>:0 
  at System.Net.Sockets.SocketAsyncResult.Complete (System.Int32 total) [0x00007] in <9452bf5cef7942ad958da6bd6bb9647c>:0 
  at System.Net.Sockets.Socket+<>c.<.cctor>b__306_8 (System.IOAsyncResult ares) [0x0004f] in <9452bf5cef7942ad958da6bd6bb9647c>:0 
  at System.IOSelectorJob.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in <9452bf5cef7942ad958da6bd6bb9647c>:0 
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in <d9b55d9a4bc046648dbe0b2040413b94>:0 
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <d9b55d9a4bc046648dbe0b2040413b94>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.Threading.SemaphoreFullException: Adding the specified count to the semaphore would cause it to exceed its maximum count.
  at System.Threading.SemaphoreSlim.Release (System.Int32 releaseCount) [0x0004c] in <d9b55d9a4bc046648dbe0b2040413b94>:0 
  at System.Threading.SemaphoreSlim.Release () [0x00000] in <d9b55d9a4bc046648dbe0b2040413b94>:0 
  at System.Net.Sockets.SocketAsyncResult.Complete () [0x000aa] in <9452bf5cef7942ad958da6bd6bb9647c>:0 
  at System.Net.Sockets.SocketAsyncResult.Complete (System.Int32 total) [0x00007] in <9452bf5cef7942ad958da6bd6bb9647c>:0 
  at System.Net.Sockets.Socket+<>c.<.cctor>b__306_8 (System.IOAsyncResult ares) [0x0004f] in <9452bf5cef7942ad958da6bd6bb9647c>:0 
  at System.IOSelectorJob.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in <9452bf5cef7942ad958da6bd6bb9647c>:0 
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in <d9b55d9a4bc046648dbe0b2040413b94>:0 
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <d9b55d9a4bc046648dbe0b2040413b94>:0
Comment 7 apollo_maverick 2017-02-10 05:50:16 UTC
@Ludovic checked?
Comment 8 Ludovic Henry 2017-02-10 20:00:57 UTC
I can reproduce with mono master, I am working on it.
Comment 9 Ludovic Henry 2017-02-13 17:22:44 UTC
This is fixed with https://github.com/mono/mono/pull/4369
Comment 10 Matt Z 2017-03-03 05:05:20 UTC
Why was the above PR closed without being merged?
Comment 11 Ludovic Henry 2017-03-03 13:41:58 UTC
The PR was simply split in 3 smaller PR, and the one that fixes this bug is https://github.com/mono/mono/pull/4389