Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to create a thread shouldn't assume that this an out of memory issue #71761

Open
ayende opened this issue Jul 7, 2022 · 1 comment
Open
Assignees
Milestone

Comments

@ayende
Copy link
Contributor

ayende commented Jul 7, 2022

Description

The code here:

https://github.com/dotnet/runtime/blob/main/src/coreclr/vm/threads.cpp#L812

Assumes that failing to create a thread means that we run out of memory.
This result in this error:

---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at System.Threading.Thread.StartInternal(ThreadHandle t, Int32 stackSize, Int32 priority, Char* pThreadName)
   at System.Threading.Thread.StartCore()

On Linux, there are few other options, such as the TasksMax limit (at process or user level), global number of processes limit at the kernel level.

Reproduction Steps

Set a low TasksMax limit and create more threads than allowed.

Expected behavior

Getting an error saying that the thread failed to start, and either pointing the actual reason for that or listing the various options.

Actual behavior

Getting a misleading exception pointing in the wrong direction.

Regression?

No response

Known Workarounds

No response

Configuration

Linux - systemd

In particular, running a server which spawns threads on need. You'll get OutOfMemoryException even if you have lots of room available.

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jul 7, 2022
@ghost
Copy link

ghost commented Jul 7, 2022

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

The code here:

https://github.com/dotnet/runtime/blob/main/src/coreclr/vm/threads.cpp#L812

Assumes that failing to create a thread means that we run out of memory.
This result in this error:

---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at System.Threading.Thread.StartInternal(ThreadHandle t, Int32 stackSize, Int32 priority, Char* pThreadName)
   at System.Threading.Thread.StartCore()

On Linux, there are few other options, such as the TasksMax limit (at process or user level), global number of processes limit at the kernel level.

Reproduction Steps

Set a low TasksMax limit and create more threads than allowed.

Expected behavior

Getting an error saying that the thread failed to start, and either pointing the actual reason for that or listing the various options.

Actual behavior

Getting a misleading exception pointing in the wrong direction.

Regression?

No response

Known Workarounds

No response

Configuration

Linux - systemd

In particular, running a server which spawns threads on need. You'll get OutOfMemoryException even if you have lots of room available.

Other information

No response

Author: ayende
Assignees: -
Labels:

area-System.Threading, untriaged

Milestone: -

@mangod9 mangod9 removed the untriaged New issue has not been triaged by the area owner label Jul 7, 2022
@mangod9 mangod9 added this to the 8.0.0 milestone Jul 7, 2022
@janvorli janvorli assigned janvorli and unassigned eduardo-vp Nov 22, 2022
@mangod9 mangod9 modified the milestones: 8.0.0, Future Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants