Skip to content

[release/10.0] Fix Linux madvise() advice values#128605

Merged
JulieLeeMSFT merged 1 commit into
dotnet:release/10.0from
janvorli:backport-fix-madvise-advice-values
May 27, 2026
Merged

[release/10.0] Fix Linux madvise() advice values#128605
JulieLeeMSFT merged 1 commit into
dotnet:release/10.0from
janvorli:backport-fix-madvise-advice-values

Conversation

@janvorli
Copy link
Copy Markdown
Member

Backport of #126966 to release/10.0

Customer Impact

  • Customer reported
  • Found internally

VirtualReset in GC was combining MADV_FREE (8) and MADV_DONTDUMP (16) via bitwise OR and passing the result (24) to a single madvise call. madvise takes a single advice constant — not a bitmask — so this was either rejected as EINVAL (kernels < 5.18) or silently matched MADV_DONTNEED_LOCKED (kernels ≥ 5.18), a completely different operation.

Regression

Testing

CI tests, local testing using targeted repro app from the customer, GC tests

Risk

Low. It is a simple targeted fix that just makes two calls to madvise with correct arguments where we were making one call with a combination of those values that had no effect or was outright wrong.

@janvorli janvorli added this to the 10.0.x milestone May 26, 2026
@janvorli janvorli requested a review from jkotas May 26, 2026 20:10
@janvorli janvorli self-assigned this May 26, 2026
Copilot AI review requested due to automatic review settings May 26, 2026 20:10
@janvorli janvorli added the Servicing-consider Issue for next servicing release review label May 26, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @dotnet/gc
See info in area-owners.md if you want to be subscribed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This backport fixes GCToOSInterface::VirtualReset on Unix by ensuring Linux madvise() receives a single advice constant per call (rather than an invalid bitwise-OR combination), restoring correct page-reclaim behavior and avoiding unintended advice interpretation on newer kernels.

Changes:

  • Split the combined madvise() call into two independent calls: one for MADV_DONTDUMP (coredump hint) and one for MADV_FREE (page-reclaim hint).
  • Use #ifdef MADV_FREE as the compile-time guard (instead of HAVE_MADV_FREE) and make posix_madvise(POSIX_MADV_DONTNEED) a proper fallback only when MADV_FREE isn’t available.

Copy link
Copy Markdown
Member

@JulieLeeMSFT JulieLeeMSFT left a comment

Choose a reason for hiding this comment

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

@JulieLeeMSFT
Copy link
Copy Markdown
Member

/ba-g known issues.

@JulieLeeMSFT JulieLeeMSFT merged commit 8ccd798 into dotnet:release/10.0 May 27, 2026
113 of 120 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-GC-coreclr Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants