Bug 51594 - GC thread not created and hangs in pthread_cond_wait on exiting when stack size is too big
Summary: GC thread not created and hangs in pthread_cond_wait on exiting when stack si...
Alias: None
Product: Runtime
Classification: Mono
Component: General ()
Version: 4.6.0 (C8)
Hardware: PC Linux
: --- normal
Target Milestone: Future Cycle (TBD)
Assignee: Bugzilla
Depends on:
Reported: 2017-01-18 01:46 UTC by Menci
Modified: 2017-08-17 17:28 UTC (History)
3 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 Menci 2017-01-18 01:46:34 UTC
The mono version I'm using:
# mono --version
Mono JIT compiler version 4.6.2 (Stable Tue Jan  3 11:48:26 UTC 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            sgen

My OS:
root@Menci-Laptop:/home/Menci# cat /etc/os-release 
NAME="elementary OS"
VERSION="0.4 Loki"
PRETTY_NAME="elementary OS 0.4 Loki"
root@Menci-Laptop:/home/Menci# cat /etc/lsb-release 
DISTRIB_DESCRIPTION="elementary OS 0.4 Loki"
root@Menci-Laptop:/home/Menci# uname -a
Linux Menci-Laptop 4.4.0-59-generic #80-Ubuntu SMP Fri Jan 6 17:47:47 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Mono packages:
root@Menci-Laptop:/home/Menci# dpkg -l | grep mono
ii  ca-certificates-mono                                                                         all          Common CA certificates (Mono keystore)
ii  fonts-noto-mono                                                  20160116-1                                              all          "No Tofu" monospaced font family with large Unicode coverage
ii  fonts-roboto-mono-elementary                                     0.2.1-0+r26~ubuntu0.4.1                                 all          Monospaced addition to the Roboto type family
ii  fonts-tlwg-mono                                                  1:0.6.2-2.1                                             all          Thai TlwgMono font (dependency package)
ii  fonts-tlwg-mono-ttf                                              1:0.6.2-2.1                                             all          Thai TlwgMono TrueType font
ii  libmono-2.0-dev                                                                              amd64        Mono JIT library - Development files (Default version)
ii  libmono-accessibility4.0-cil                                                                 all          Mono Accessibility library (for CLI 4.0)
ii  libmono-cairo4.0-cil                                                                         all          Mono Cairo library (for CLI 4.0)
ii  libmono-cecil-private-cil                                                                    all          Mono.Cecil library
ii  libmono-cecil-vb0.9-cil                                          4.0.1-1                                                 all          Visual Basic 2012 Cecil libraries for Mono
ii  libmono-cil-dev                                                                              all          Mono Base Class Libraries (BCL) - Development files
ii  libmono-codecontracts4.0-cil                                                                 all          Mono.CodeContracts library (for CLI 4.0)
ii  libmono-compilerservices-symbolwriter4.0-cil                                                 all          Mono.CompilerServices.SymbolWriter library (for CLI 4.0)
ii  libmono-corlib4.5-cil                                                                        all          Mono core library (for CLI 4.5)
ii  libmono-cscompmgd0.0-cil                                                                     all          Mono cscompmgd library (for CLI 4.0)
ii  libmono-csharp4.0c-cil                                                                       all          Mono.CSharp library (for CLI 4.0)
ii  libmono-custommarshalers4.0-cil                                                              all          Mono CustomMarshalers library (for CLI 4.0)
ii  libmono-data-tds4.0-cil                                                                      all          Mono Data Library (for CLI 4.0)
ii  libmono-db2-1.0-cil                                                                          all          Mono DB2 library
ii  libmono-debugger-soft4.0a-cil                                                                all          Mono Soft Debugger library (for CLI 4.0)
ii  libmono-http4.0-cil                                                                          all          Mono.Http library (for CLI 4.0)
ii  libmono-i18n-cjk4.0-cil                                                                      all          Mono I18N.CJK library (for CLI 4.0)
ii  libmono-i18n-mideast4.0-cil                                                                  all          Mono I18N.MidEast library (for CLI 4.0)
ii  libmono-i18n-other4.0-cil                                                                    all          Mono I18N.Other library (for CLI 4.0)
ii  libmono-i18n-rare4.0-cil                                                                     all          Mono I18N.Rare library (for CLI 4.0)
ii  libmono-i18n-west4.0-cil                                                                     all          Mono I18N.West library (for CLI 4.0)
ii  libmono-i18n4.0-all                                                                          all          Mono I18N libraries metapackage (for CLI 4.0)
ii  libmono-i18n4.0-cil                                                                          all          Mono I18N base library (for CLI 4.0)
ii  libmono-ldap4.0-cil                                                                          all          Mono LDAP library (for CLI 4.0)
ii  libmono-management4.0-cil                                                                    all          Mono Management library (for CLI 4.0)
ii  libmono-messaging-rabbitmq4.0-cil                                                            all          Mono Messaging RabbitMQ library (for CLI 4.0)
ii  libmono-messaging4.0-cil                                                                     all          Mono Messaging library (for CLI 4.0)
ii  libmono-microsoft-build-engine4.0-cil                                                        all          Mono Microsoft.Build.Engine library (for CLI 4.0)
ii  libmono-microsoft-build-framework4.0-cil                                                     all          Mono Microsoft.Build.Framework library (for CLI 4.0)
ii  libmono-microsoft-build-tasks-v4.0-4.0-cil                                                   all          Mono Microsoft.Build.Tasks.v4.0 library (for CLI 4.0)
ii  libmono-microsoft-build-utilities-v4.0-4.0-cil                                               all          Mono Microsoft.Build.Utilities.v4.0 library (for CLI 4.0)
ii  libmono-microsoft-build4.0-cil                                                               all          Mono Microsoft.Build library (for CLI 4.0)
ii  libmono-microsoft-csharp4.0-cil                                                              all          Mono Microsoft.CSharp library (for CLI 4.0)
ii  libmono-microsoft-visualbasic10.0-cil                            4.0.1-1                                                 all          Visual Basic 2012 runtime libraries for Mono
ii  libmono-microsoft-visualc10.0-cil                                                            all          Mono Microsoft.VisualC library (for CLI 4.0)
ii  libmono-microsoft-web-infrastructure1.0-cil                                                  all          Mono Microsoft.Web.Infrastructure library (for CLI 4.0)
ii  libmono-oracle4.0-cil                                                                        all          Mono Oracle library (for CLI 4.0)
ii  libmono-parallel4.0-cil                                                                      all          Mono.Parallel library (for CLI 4.0)
ii  libmono-peapi4.0a-cil                                                                        all          Mono PEAPI library (for CLI 4.0)
ii  libmono-posix4.0-cil                                                                         all          Mono.Posix library (for CLI 4.0)
ii  libmono-rabbitmq4.0-cil                                                                      all          Mono RabbitMQ.Client library (for CLI 4.0)
ii  libmono-relaxng4.0-cil                                                                       all          Mono Relaxng library (for CLI 4.0)
ii  libmono-security4.0-cil                                                                      all          Mono Security library (for CLI 4.0)
ii  libmono-sharpzip4.84-cil                                                                     all          Mono SharpZipLib library (for CLI 4.0)
ii  libmono-simd4.0-cil                                                                          all          Mono SIMD (for CLI 4.0)
ii  libmono-smdiagnostics0.0-cil                                                                 all          Mono SMDiagnostics Library (for CLI 4.0)
ii  libmono-sqlite4.0-cil                                                                        all          Mono Sqlite library (for CLI 4.0)
ii  libmono-system-componentmodel-composition4.0-cil                                             all          Mono System.ComponentModel.Composition library (for CLI 4.0)
ii  libmono-system-componentmodel-dataannotations4.0-cil                                         all          Mono System.ComponentModel.DataAnnotations library (for CLI 4.0)
ii  libmono-system-configuration-install4.0-cil                                                  all          Mono System.Configuration.Install library (for CLI 4.0)
ii  libmono-system-configuration4.0-cil                                                          all          Mono System.Configuration library (for CLI 4.0)
ii  libmono-system-core4.0-cil                                                                   all          Mono System.Core library (for CLI 4.0)
ii  libmono-system-data-datasetextensions4.0-cil                                                 all          Mono System.Data.DataSetExtensions library (for CLI 4.0)
ii  libmono-system-data-entity4.0-cil                                                            all          Mono System.Data.Entity library (for CLI 4.0)
ii  libmono-system-data-linq4.0-cil                                                              all          Mono System.Data.Linq Library (for CLI 4.0)
ii  libmono-system-data-services-client4.0-cil                                                   all          Mono System.Data.Services.Client library (for CLI 4.0)
ii  libmono-system-data-services4.0-cil                                                          all          Mono System.Data.Services library (for CLI 4.0)
ii  libmono-system-data4.0-cil                                                                   all          Mono System.Data library (for CLI 4.0)
ii  libmono-system-deployment4.0-cil                                                             all          Mono System.Deployment library (for CLI 4.0)
ii  libmono-system-design4.0-cil                                                                 all          Mono System.Design Library (for CLI 4.0)
ii  libmono-system-drawing-design4.0-cil                                                         all          Mono System.Drawing.Design (for CLI 4.0)
ii  libmono-system-drawing4.0-cil                                                                all          Mono System.Drawing library (for CLI 4.0)
ii  libmono-system-dynamic4.0-cil                                                                all          Mono System.Dynamic library (for CLI 4.0)
ii  libmono-system-enterpriseservices4.0-cil                                                     all          Mono System.EnterpriseServices library (for CLI 4.0)
ii  libmono-system-identitymodel-selectors4.0-cil                                                all          Mono System.IdentityModel.Selectors Library (for CLI 4.0)
ii  libmono-system-identitymodel4.0-cil                                                          all          Mono System.IdentityModel Library (for CLI 4.0)
ii  libmono-system-io-compression-filesystem4.0-cil                                              all          Mono System.IO.Compresion.FileSystem library (for CLI 4.0)
ii  libmono-system-io-compression4.0-cil                                                         all          Mono System.IO.Compression library (for CLI 4.0)
ii  libmono-system-json-microsoft4.0-cil                                                         all          Mono System.Json.Microsoft library (for CLI 4.0)
ii  libmono-system-json4.0-cil                                                                   all          Mono System.Json library (for CLI 4.0)
ii  libmono-system-ldap-protocols4.0-cil                                                         all          Mono System.DirectoryServices.Protocols library (for CLI 4.0)
ii  libmono-system-ldap4.0-cil                                                                   all          Mono System.DirectoryServices library (for CLI 4.0)
ii  libmono-system-management4.0-cil                                                             all          Mono System.Management library (for CLI 4.0)
ii  libmono-system-messaging4.0-cil                                                              all          Mono System.Messaging library (for CLI 4.0)
ii  libmono-system-net-http-formatting4.0-cil                                                    all          Mono System.Net.Http.Formatting library (for CLI 4.0)
ii  libmono-system-net-http-webrequest4.0-cil                                                    all          Mono System.Net.Http.WebRequest library (for CLI 4.0)
ii  libmono-system-net-http4.0-cil                                                               all          Mono System.Net.Http library (for CLI 4.0)
ii  libmono-system-net4.0-cil                                                                    all          Mono System.Net library (for CLI 4.0)
ii  libmono-system-numerics-vectors4.0-cil                                                       all          Mono System.Numerics.Vectors library (for CLI 4.0)
ii  libmono-system-numerics4.0-cil                                                               all          Mono System.Numerics library (for CLI 4.0)
ii  libmono-system-reactive-core2.2-cil                                                          all          Mono System.Reactive.Core Library (for CLI 4.5)
ii  libmono-system-reactive-debugger2.2-cil                                                      all          Mono System.Reactive.Debugger Library (for CLI 4.5)
ii  libmono-system-reactive-experimental2.2-cil                                                  all          Mono System.Reactive.Experimental Library (for CLI 4.5)
ii  libmono-system-reactive-interfaces2.2-cil                                                    all          Mono System.Reactive.Interfaces Library (for CLI 4.5)
ii  libmono-system-reactive-linq2.2-cil                                                          all          Mono System.Reactive.Linq Library (for CLI 4.5)
ii  libmono-system-reactive-observable-aliases0.0-cil                                            all          Mono System.Reactive.Linq Library (for CLI 4.5)
ii  libmono-system-reactive-platformservices2.2-cil                                              all          Mono System.Reactive.PlatformServices Library (for CLI 4.5)
ii  libmono-system-reactive-providers2.2-cil                                                     all          Mono System.Reactive.Providers Library (for CLI 4.5)
ii  libmono-system-reactive-runtime-remoting2.2-cil                                              all          Mono System.Reactive.Runtime.Remoting Library (for CLI 4.5)
ii  libmono-system-reactive-windows-forms2.2-cil                                                 all          Mono System.Reactive.Windows.Forms Library (for CLI 4.5)
ii  libmono-system-reactive-windows-threading2.2-cil                                             all          Mono System.Reactive.Windows.Threading Library (for CLI 4.5)
ii  libmono-system-reflection-context4.0-cil                                                     all          Mono System.Reflection.Context library (for CLI 4.0)
ii  libmono-system-runtime-caching4.0-cil                                                        all          Mono System.Runtime.Caching Library (for CLI 4.0)
ii  libmono-system-runtime-durableinstancing4.0-cil                                              all          Mono System.Runtime.DurableInstancing Library (for CLI 4.0)
ii  libmono-system-runtime-interopservices-runtimeinformation4.0-cil                                      all          Mono System.Runtime.InteropServices.RuntimeInformation library
ii  libmono-system-runtime-serialization-formatters-soap4.0-cil                                      all          Mono System.Runtime.Serialization.Formatters.Soap Library (for CLI 4.0)
ii  libmono-system-runtime-serialization4.0-cil                                                  all          Mono System.Runtime.Serialization Library (for CLI 4.0)
ii  libmono-system-runtime4.0-cil                                                                all          Mono System.Runtime library (for CLI 4.0)
ii  libmono-system-security4.0-cil                                                               all          Mono System.Security library (for CLI 4.0)
ii  libmono-system-servicemodel-activation4.0-cil                                                all          Mono System.ServiceModel.Activation Library (for CLI 4.0)
ii  libmono-system-servicemodel-discovery4.0-cil                                                 all          Mono System.ServiceModel.Discovery Library (for CLI 4.0)
ii  libmono-system-servicemodel-internals0.0-cil                                                 all          Mono System.ServiceModel.Internals Library (for CLI 4.0)
ii  libmono-system-servicemodel-routing4.0-cil                                                   all          Mono System.ServiceModel.Routing Library (for CLI 4.0)
ii  libmono-system-servicemodel-web4.0-cil                                                       all          Mono System.ServiceModel.Web Library (for CLI 4.0)
ii  libmono-system-servicemodel4.0a-cil                                                          all          Mono System.ServiceModel Library (for CLI 4.0)
ii  libmono-system-serviceprocess4.0-cil                                                         all          Mono System.ServiceProcess library (for CLI 4.0)
ii  libmono-system-threading-tasks-dataflow4.0-cil                                               all          Mono System.Threading.Tasks.Dataflow library (for CLI 4.0)
ii  libmono-system-transactions4.0-cil                                                           all          Mono System.Transactions library (for CLI 4.0)
ii  libmono-system-web-abstractions4.0-cil                                                       all          Mono System.Web.Abstractions library (for CLI 4.0)
ii  libmono-system-web-applicationservices4.0-cil                                                all          Mono System.Web.ApplicationServices library (for CLI 4.0)
ii  libmono-system-web-dynamicdata4.0-cil                                                        all          Mono System.Web.DynamicData library (for CLI 4.0)
ii  libmono-system-web-extensions-design4.0-cil                                                  all          Mono System.Web.Extensions.Design library (for CLI 4.0)
ii  libmono-system-web-extensions4.0-cil                                                         all          Mono System.Web.Extensions library (for CLI 4.0)
ii  libmono-system-web-http-selfhost4.0-cil                                                      all          Mono System.Web.Http.SelfHost library (for CLI 4.0)
ii  libmono-system-web-http-webhost4.0-cil                                                       all          Mono System.Web.Http.WebHost library (for CLI 4.0)
ii  libmono-system-web-http4.0-cil                                                               all          Mono System.Web.Http library (for CLI 4.0)
ii  libmono-system-web-mobile4.0-cil                                                             all          Mono System.Web.Mobile library (for CLI 4.0)
ii  libmono-system-web-mvc3.0-cil                                                                all          Mono ASP.NET MVC 3.0 Library (for CLI 4.0)
ii  libmono-system-web-razor2.0-cil                                                              all          Mono System.Web.Razor (for CLI 4.0)
ii  libmono-system-web-regularexpressions4.0-cil                                                 all          Mono System.Web.RegularExpressions library (for CLI 4.0)
ii  libmono-system-web-routing4.0-cil                                                            all          Mono System.Web.Routing (for CLI 4.0)
ii  libmono-system-web-services4.0-cil                                                           all          Mono System.Web.Services (for CLI 4.0)
ii  libmono-system-web-webpages-deployment2.0-cil                                                all          Mono System.Web.WebPages.Deployment (for CLI 4.0)
ii  libmono-system-web-webpages-razor2.0-cil                                                     all          Mono System.Web.WebPages.Razor (for CLI 4.0)
ii  libmono-system-web-webpages2.0-cil                                                           all          Mono System.Web.WebPages (for CLI 4.0)
ii  libmono-system-web4.0-cil                                                                    all          Mono System.Web library (for CLI 4.0)
ii  libmono-system-windows-forms-datavisualization4.0a-cil                                       all          Mono System.Windows.Forms.DataVisualization Library (for CLI 4.0)
ii  libmono-system-windows-forms4.0-cil                                                          all          Mono System.Windows.Forms Library (for CLI 4.0)
ii  libmono-system-windows4.0-cil                                                                all          Mono System.Windows library (for CLI 4.0)
ii  libmono-system-workflow-activities4.0-cil                                                    all          Mono System.Workflow.Activities library (for CLI 4.0)
ii  libmono-system-workflow-componentmodel4.0-cil                                                all          Mono System.Workflow.ComponentModel library (for CLI 4.0)
ii  libmono-system-workflow-runtime4.0-cil                                                       all          Mono System.Workflow.Runtime library (for CLI 4.0)
ii  libmono-system-xaml4.0-cil                                                                   all          Mono System.Xaml Library (for CLI 4.0)
ii  libmono-system-xml-linq4.0-cil                                                               all          Mono System.Xml.Linq library (for CLI 4.0)
ii  libmono-system-xml-serialization4.0-cil                                                      all          Mono System.Xml.Serialization library (for CLI 4.0)
ii  libmono-system-xml4.0-cil                                                                    all          Mono System.Xml library (for CLI 4.0)
ii  libmono-system4.0-cil                                                                        all          Mono System libraries (for CLI 4.0)
ii  libmono-tasklets4.0-cil                                                                      all          Mono Tasklets library (for CLI 4.0)
ii  libmono-webbrowser4.0-cil                                                                    all          Mono Web Browser library (for CLI 4.0)
ii  libmono-webmatrix-data4.0-cil                                                                all          Mono WebMatrix.Data Library (for CLI 4.0)
ii  libmono-windowsbase4.0-cil                                                                   all          Mono WindowsBase library (for CLI 4.0)
ii  libmono-xbuild-tasks4.0-cil                                                                  all          Mono Mono.XBuild.Tasks library (for CLI 4.0)
ii  libmonosgen-2.0-1                                                                            amd64        Mono JIT library (SGen GC)
ii  libmonosgen-2.0-1-dbg                                                                        amd64        Mono JIT library, debugging symbols (SGen GC)
ii  libmonosgen-2.0-dev                                                                          amd64        Mono JIT library - Development files (SGen GC)
ii  libnuget-core-cil                                                2.12+mono-0xamarin1                                     all          Package manager for NuGet repos - library
ii  mono-4.0-gac                                                                                 all          Mono GAC tool (for CLI 4.0)
ii  mono-csharp-shell                                                                            all          interactive C# shell
ii  mono-dbg                                                                                     all          Mono debugging symbols
ii  mono-devel                                                                                   all          Mono development tools
ii  mono-gac                                                                                     all          Mono GAC tool
ii  mono-mcs                                                                                     all          Mono C# 2.0 / 3.0 / 4.0 / 5.0  compiler for CLI 2.0 / 4.0 / 4.5
ii  mono-runtime                                                                                 amd64        Mono runtime - default version
ii  mono-runtime-boehm                                                                           amd64        Mono runtime - Boehm
ii  mono-runtime-common                                                                          amd64        Mono runtime - common files
ii  mono-runtime-dbg                                                                             amd64        Mono runtime, debugging symbols
ii  mono-runtime-sgen                                                                            amd64        Mono runtime - SGen
ii  mono-vbnc                                                        4.0.1-1                                                 all          Mono Visual Basic Compiler (VB.NET)
ii  mono-xbuild                                                                                  all          MSBuild-compatible build system for Mono
ii  mono-xsp                                                         4.2-2build1                                             all          simple web server to run ASP.NET applications - default version
ii  mono-xsp4                                                        4.2-2build1                                             all          simple web server to run ASP.NET 4.0 applications
ii  mono-xsp4-base                                                   4.2-2build1                                             all          base libraries for XSP 4.0
ii  monodevelop                                                                                        all          Development Environment for GNOME
ii  monodoc-base                                                                                 all          shared MonoDoc binaries
ii  monodoc-manual                                                                               all          compiled XML documentation from the Mono project
ii  nuget                                                            2.12+mono-0xamarin1                                     all          Package manager for NuGet repos - executable
ii  ubuntu-mono                                                      14.04+16.04.20161024-0ubuntu1                           all          Ubuntu Mono Icon theme

Start mono with gdb with a lower (or default) stack size:
root@Menci-Laptop:/home/Menci# ulimit -s 128000
root@Menci-Laptop:/home/Menci# gdb mono
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
Find the GDB manual and other documentation resources online at:
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from mono...Reading symbols from /usr/lib/debug//usr/bin/mono-sgen...done.
Mono support loaded.
Mono support loaded.
(gdb) r /tmp/tmp_DYlBkABHIArfAHNM7LmrdUdQklEooyr2.exe < /tmp/1.in
Starting program: /usr/bin/mono /tmp/tmp_DYlBkABHIArfAHNM7LmrdUdQklEooyr2.exe < /tmp/1.in
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff53ff700 (LWP 32664)]
[New Thread 0x7fffebb34700 (LWP 32665)]
[Thread 0x7fffebb34700 (LWP 32665) exited]
[Thread 0x7ffff53ff700 (LWP 32664) exited]
[Inferior 1 (process 32660) exited normally]

Noticed that two threads was created.

Run mono again with a big stack size limit:
# ulimit -s 12800000
# gdb -q mono
Reading symbols from mono...Reading symbols from /usr/lib/debug//usr/bin/mono-sgen...done.
Mono support loaded.
Mono support loaded.
(gdb) r /tmp/tmp_DYlBkABHIArfAHNM7LmrdUdQklEooyr2.exe < /tmp/1.in
Starting program: /usr/bin/mono /tmp/tmp_DYlBkABHIArfAHNM7LmrdUdQklEooyr2.exe < /tmp/1.in
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffcee435700 (LWP 31259)]
Thread 1 "Main" received signal SIGINT, Interrupt.
pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
185	../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: No such file or directory.
(gdb) bt
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x0000000000623694 in mono_os_cond_wait (cond=0x98a460 <done_cond>, mutex=<optimized out>) at ../../mono/utils/mono-os-mutex.h:107
#2  sgen_thread_pool_job_wait (job=0x7ffcf2bdc010) at sgen-thread-pool.c:227
#3  0x000000000060cd61 in major_finish_sweep_checking () at sgen-marksweep.c:855
#4  major_finish_sweep_checking () at sgen-marksweep.c:818
#5  0x0000000000618fab in sgen_memgov_major_collection_end (forced=1, concurrent=0, reason=0x702a50 "user request", is_overflow=0) at sgen-memory-governor.c:277
#6  0x0000000000606fb2 in major_finish_collection (reason=reason@entry=0x702a50 "user request", is_overflow=is_overflow@entry=0, old_next_pin_slot=<optimized out>, 
    forced=forced@entry=1) at sgen-gc.c:2043
#7  0x000000000060719a in major_do_collection (forced=1, is_overflow=0, reason=0x702a50 "user request") at sgen-gc.c:2083
#8  major_do_collection (reason=0x702a50 "user request", is_overflow=0, forced=1) at sgen-gc.c:2065
#9  0x0000000000607854 in sgen_perform_collection (requested_size=0, generation_to_collect=1, reason=0x702a50 "user request", wait_to_finish=1, stw=1) at sgen-gc.c:2279
#10 0x0000000000607cf9 in sgen_gc_collect (generation=1) at sgen-gc.c:2692
#11 0x00000000005ec4a5 in mono_gc_collect (generation=<optimized out>) at sgen-mono.c:2555
#12 0x00000000005bc12c in mono_domain_finalize (domain=domain@entry=0x9cf380, timeout=timeout@entry=2000) at gc.c:413
#13 0x00000000004245c4 in mini_cleanup (domain=0x9cf380) at mini-runtime.c:4046
#14 0x000000000047eb5f in mono_main (argc=2, argv=<optimized out>) at driver.c:2143
#15 0x0000000000422258 in mono_main_with_options (argv=0x7fffffffdd58, argc=2) at main.c:28
#16 main (argc=2, argv=0x7fffffffdd58) at main.c:177

Noticed only one thread was created, and program hangs after printed the output and returned from `MainClass::Main`. I 
interrupted it with C-c and it stops in `pthread_cond_wait`.

I think it's waiting for the non-exist thread.

Now run mono again with boehm GC.
root@Menci-Laptop:/home/Menci# ulimit -s 128000000
root@Menci-Laptop:/home/Menci# gdb -q mono-boehm
Reading symbols from mono-boehm...Reading symbols from /usr/lib/debug//usr/bin/mono-boehm...done.
(gdb) r /tmp/tmp_DYlBkABHIArfAHNM7LmrdUdQklEooyr2.exe < /tmp/1.in
Starting program: /usr/bin/mono-boehm /tmp/tmp_DYlBkABHIArfAHNM7LmrdUdQklEooyr2.exe < /tmp/1.in
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
GC Warning: Marker thread creation failed, errno = 12.
GC Warning: Marker thread creation failed, errno = 12.
GC Warning: Marker thread creation failed, errno = 12.
[New Thread 0x7fe178d71700 (LWP 892)]

Thread 2 "Finalizer" received signal SIGPWR, Power fail/restart.
[Switching to Thread 0x7fe178d71700 (LWP 892)]
0x00007fe17acb4827 in futex_abstimed_wait_cancelable (private=0, abstime=0x0, expected=0, futex_word=0x955ba0 <finalizer_sem>)
    at ../sysdeps/unix/sysv/linux/futex-internal.h:205
205	../sysdeps/unix/sysv/linux/futex-internal.h: No such file or directory.
(gdb) bt
#0  0x00007fe17acb4827 in futex_abstimed_wait_cancelable (private=0, abstime=0x0, expected=0, futex_word=0x955ba0 <finalizer_sem>)
    at ../sysdeps/unix/sysv/linux/futex-internal.h:205
#1  do_futex_wait (sem=sem@entry=0x955ba0 <finalizer_sem>, abstime=0x0) at sem_waitcommon.c:111
#2  0x00007fe17acb48d4 in __new_sem_wait_slow (sem=0x955ba0 <finalizer_sem>, abstime=0x0) at sem_waitcommon.c:181
#3  0x00007fe17acb497a in __new_sem_wait (sem=sem@entry=0x955ba0 <finalizer_sem>) at sem_wait.c:29
#4  0x00000000005c303c in mono_os_sem_wait (flags=MONO_SEM_FLAGS_ALERTABLE, sem=0x955ba0 <finalizer_sem>) at ../../mono/utils/mono-os-semaphore.h:166
#5  mono_coop_sem_wait (sem=<optimized out>, flags=<optimized out>) at ../../mono/utils/mono-coop-semaphore.h:40
#6  finalizer_thread (unused=unused@entry=0x0) at gc.c:761
#7  0x00000000005a388c in start_wrapper_internal (data=<optimized out>) at threads.c:740
#8  start_wrapper (data=<optimized out>) at threads.c:788
#9  0x000000000062514c in inner_start_thread (arg=<optimized out>) at mono-threads-posix.c:92
#10 0x0000000000636fb4 in GC_start_routine (arg=<optimized out>) at pthread_support.c:1508
#11 0x00007fe17acac6ba in start_thread (arg=0x7fe178d71700) at pthread_create.c:333
#12 0x00007fe17a7cc82d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

There're some error output from mono, and my program doesn't printed anything.

If I run mono-boehm without GDB, it outputs the error log and my program printed its output correctly and returned 0.

root@Menci-Laptop:/home/Menci# ulimit -s 128000000
root@Menci-Laptop:/home/Menci# mono-boehm /tmp/tmp_DYlBkABHIArfAHNM7LmrdUdQklEooyr2.exe < /tmp/1.in
GC Warning: Marker thread creation failed, errno = 12.
GC Warning: Marker thread creation failed, errno = 12.
GC Warning: Marker thread creation failed, errno = 12.
root@Menci-Laptop:/home/Menci# echo $?
Comment 1 Ludovic Henry 2017-07-06 15:03:57 UTC

Could you please provide a repro case so we can run that on our end? Also could you please test with latest stable mono (5.0 on ubuntu), and let us know if you can still reproduce?

Thank you,
Comment 2 Ludovic Henry 2017-08-17 17:28:29 UTC
Please reopen whenever you provide a reproduction case so we can have a look. Thank you.