Bug 35297 - Hang possibly due to Parallel.ForEach threadpool thread preventing console application exit
Summary: Hang possibly due to Parallel.ForEach threadpool thread preventing console ap...
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 4.0.0
Hardware: Other Linux
: --- normal
Target Milestone: Untriaged
Assignee: Ludovic Henry
Depends on:
Reported: 2015-10-27 12:38 UTC by Eric Roller
Modified: 2015-11-20 18:37 UTC (History)
3 users (show)

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

stacktrace during the hang (console application code has already finished executing) (2.30 KB, text/plain)
2015-10-27 12:38 UTC, Eric Roller

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 Eric Roller 2015-10-27 12:38:49 UTC
Created attachment 13543 [details]
stacktrace during the hang (console application code has already finished executing)

Running mono 4.0.2 on Linux compute node (40 cores and 128GB RAM). Console application calls Parallel.ForEach. Approximately 1 in every 200 runs of the application will hang. All the work and output from the console application is already generated so it appears all the application code has finished executing. The process just does not exit.

I actually don't know for sure that the call to Parallel.ForEach is the reason for the hang, but it seems the most likely possibility since it is the only part of the code that uses multi-threading. 

The stacktrace from gdb is attached. 3 threads are running.
Comment 1 Ludovic Henry 2015-11-05 09:06:49 UTC
Hi Eric,

Did you have the chance to try with mono 4.2? If yes, did you hit the same bug (or any other one) ?

This seems like a bug with the previous implementation of the threadpool. Mono 4.2 introduce a new implementation based on the Microsoft one, imported from Microsoft Reference Source.

Thank you!
Comment 2 Eric Roller 2015-11-05 13:21:17 UTC
I haven't tried yet, but I was hoping it would be fixed in 4.2. Thanks for the information about the updated threadpool implementation. I will give it a try and close this out if it is fixed.
Comment 3 Eric Roller 2015-11-20 18:37:49 UTC
No problems when testing with mono This issue appears to be resolved. Thanks!