Bug 58942 - Application crashes on creating new Thread over the fixed number of threads .
Summary: Application crashes on creating new Thread over the fixed number of threads .
Status: RESOLVED NOT_ON_ROADMAP
Alias: None
Product: Runtime
Classification: Mono
Component: General ()
Version: 5.0 (2017-02)
Hardware: Other Linux
: --- normal
Target Milestone: Community
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-08-22 07:33 UTC by denis2000tw2
Modified: 2017-09-01 18:05 UTC (History)
4 users (show)

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


Attachments
test how many is the maximum number of thread (18.52 KB, application/zip)
2017-08-22 07:33 UTC, denis2000tw2
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 NOT_ON_ROADMAP

Description denis2000tw2 2017-08-22 07:33:01 UTC
Created attachment 24344 [details]
test how many is the maximum number of thread

*** Overview ***
Process need to have a lot of threads for huge amount of tcp connection.

Confirming the configuration of linux like nofile is useful
and the  process built by  c language  can hold over 30K threads on the Linux. 

But the process with mono on Linux will crash when crating the new  thread after the 18314th thread.


*** Steps to Reproduce ***
1. mono MaximumThread
2. confirm that the process is built by 64 bit, enter any key


*** Actual Results ***

Native stacktrace:

        mono() [0x4ae30f]
        /lib64/libpthread.so.0(+0xf370) [0x7f0c1fe1d370]
        /lib64/libc.so.6(gsignal+0x37) [0x7f0c1f86b1d7]
        /lib64/libc.so.6(abort+0x148) [0x7f0c1f86c8c8]
        mono() [0x674559]
        mono() [0x688f8d]
        mono() [0x689123]
        mono() [0x67bc07]
        mono() [0x67f586]
        mono() [0x67f794]
        /lib64/libpthread.so.0(+0x7dc5) [0x7f0c1fe15dc5]
        /lib64/libc.so.6(clone+0x6d) [0x7f0c1f92d6ed]

Debug info from gdb:

mono_gdb_render_native_backtraces not supported on this platform, unable to find gdb or lldb

=================================================================
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.
=================================================================

other info about process

[Debug]$ ps aux |grep mono
1357511728 417645 0.3  0.0 235232 14312 pts/1    Sl+  06:48   0:00 mono MaximumThread.exe
1357511728 417649 0.0  0.0 110456  2264 pts/0    S+   06:48   0:00 grep --color=auto mono
[Debug]$ cat /proc/417645/limits
Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
Max stack size            8388608              unlimited            bytes
Max core file size        0                    unlimited            bytes
Max resident set          unlimited            unlimited            bytes
Max processes             122590               122590               processes
Max open files            614400               614400               files
Max locked memory         65536                65536                bytes
Max address space         unlimited            unlimited            bytes
Max file locks            unlimited            unlimited            locks
Max pending signals       122590               122590               signals
Max msgqueue size         819200               819200               bytes
Max nice priority         0                    0
Max realtime priority     0                    0
Max realtime timeout      unlimited            unlimited            us

*** Environment Info ***

=== Operating System ===

Linux version 4.9.38-16.35.amzn1.x86_64 (mockbuild@gobi-build-60006) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Sat Aug 5 01:39:35 UTC 2017

Mono JIT compiler version 5.0.1.1 (2017-02/5077205 Wed May 24 13:16:08 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 (concurrent by default)

=== hardware info ===
memory : 32G
Comment 1 denis2000tw2 2017-08-22 07:34:29 UTC
Comment on attachment 24344 [details]
test how many is the maximum number of thread

*** Steps to Reproduce ***
1. mono MaximumThread
2. confirm that the process is built by 64 bit, enter any key
Comment 2 denis2000tw2 2017-08-22 07:34:44 UTC
Comment on attachment 24344 [details]
test how many is the maximum number of thread

*** Steps to Reproduce ***
1. mono MaximumThread
2. confirm that the process is built by 64 bit, enter any key
Comment 3 denis2000tw2 2017-08-22 07:35:00 UTC
Comment on attachment 24344 [details]
test how many is the maximum number of thread

*** Steps to Reproduce ***
1. mono MaximumThread
2. confirm that the process is built by 64 bit, enter any key
Comment 4 Ludovic Henry 2017-09-01 00:06:37 UTC
There is an additional overhead to creating a thread in Mono, even if it mostly relies on native threads. 

Could you install gdb or lldb and provide a stacktrace of the crash? That would help us understand where exactly do we raise the SIGABRT.

Thank you,
Comment 5 denis2000tw2 2017-09-01 07:26:21 UTC
After Installing of gdb, run the program with command "$ mono --debug MaximumThread.exe >> bug "

find the error:
* Assertion at hazard-pointer.c:101, condition `id < HAZARD_TABLE_MAX_SIZE' not met

can i increase this limit? 

Thanks
Comment 6 Ludovic Henry 2017-09-01 18:05:54 UTC
Having more than 16k threads is not a use case we will look into fixing anytime soon, so marking as not on roadmap, and if anybody from the community is interested in looking into it, please reopen and assign to yourself. Thank you!