Skip to content

stackSize override is not correct value format #60762

@clintwar

Description

@clintwar

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When aspnetcore for in process hosting overrides the default stack size for new threads on the threadpool (https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/advanced?view=aspnetcore-9.0) the value is incorrectly defaulted.

m_strStackSize = find_element(handlerSettings, CS_ASPNETCORE_HANDLER_STACK_SIZE).value_or(L"1048576");

3be11f6

The internals of coreclr is looking for the value as base16. The default value of 1048576 is treating as base16. This is not 1 MB. This is 17 MB.

If you take a memory dump of an inprocess hosted .net core 8 app and view !address -f:MEM_RESERVE,Stack you will notice reserved memory for stack around this 0x1048576 size. In 32bit world this is a bad situation as you will run out of memory if your process needs to create many threads.

In the learning document it indicates how to set it to 2MB however this actually would set it to 34~ MB.

Expected Behavior

Actually set stack to a reasonable size similar to what .net core does by default 1.5 MB for 32bit app and 4MB for x64.

Steps To Reproduce

If you take a memory dump of an inprocess hosted .net core 8 app and view !address -f:MEM_RESERVE,Stack you will notice reserved memory for stack around this 0x1048576 size. In 32bit world this is a bad situation as you will run out of memory if your process needs to create many threads.

Exceptions (if any)

No response

.NET Version

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions