Skip to content

Limit doublemapper maximum size - #119316

Merged
janvorli merged 3 commits into
dotnet:mainfrom
janvorli:limit-doublemapper-memory
Sep 4, 2025
Merged

janvorli merged 3 commits into
dotnet:mainfrom
janvorli:limit-doublemapper-memory

Conversation

@janvorli

@janvorli janvorli commented Sep 3, 2025

Copy link
Copy Markdown
Member

The double mapping currently sets the maximum size of the double mapped memory to 2TB. However, that causes the runtime to fail to start if there is a rlimit for max file size set to a smaller value.

This change fixed the problem by clipping the max double mapped memory size by that rlimit and also uses much more conservative size even without the file size limit set. It is now set to the total amount of physical memory by default and also clipped by the virtual memory rlimit.

Close #117819

The double mapping currently sets the maximum size of the double mapped memory to 2TB.
However, that causes the runtime to fail to start if there is a rlimit for max file
size set to a smaller value.

This change fixed the problem by clipping the max double mapped memory size by that
rlimit and also uses much more conservative size even without the file size limit set.
It is now set to the total amount of physical memory by default and also clipped by
the virtual memory rlimit.

Close dotnet#117819
@janvorli janvorli added this to the 10.0.0 milestone Sep 3, 2025
@janvorli
janvorli requested a review from jkotas September 3, 2025 13:29
@janvorli janvorli self-assigned this Sep 3, 2025
Copilot AI review requested due to automatic review settings September 3, 2025 13:29
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a runtime startup failure that occurs when the double mapper's maximum size exceeds system resource limits. The change replaces the hardcoded 2TB maximum with a more conservative approach that respects system constraints.

Key changes:

  • Dynamically calculates maximum size based on physical memory instead of using a fixed 2TB limit
  • Adds resource limit checking to prevent exceeding virtual address space and file size limits
  • Ensures the runtime can start successfully under restrictive rlimit configurations

Comment thread src/coreclr/minipal/Unix/doublemapping.cpp Outdated
Comment thread src/coreclr/minipal/Unix/doublemapping.cpp
Comment thread src/coreclr/minipal/Unix/doublemapping.cpp
Comment thread src/coreclr/minipal/Unix/doublemapping.cpp Outdated
Even on 32 bit targets, more than 4GB memory may be available.
@janvorli
janvorli merged commit f4a4d5c into dotnet:main Sep 4, 2025
96 checks passed
@janvorli

janvorli commented Sep 5, 2025

Copy link
Copy Markdown
Member Author

/backport to release/10.0

@github-actions

github-actions Bot commented Sep 5, 2025

Copy link
Copy Markdown
Contributor

Started backporting to release/10.0: https://github.com/dotnet/runtime/actions/runs/17495118929

@github-actions github-actions Bot locked and limited conversation to collaborators Oct 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doublemapping.cpp causes crash with SIGXFSZ if file size limits <2TB are in effect

4 participants