Fix segfault in GC standalone large pages emulation mode (segments path) - #127763
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @dotnet/gc |
86e5612 to
0aaa427
Compare
|
I am not convinced whether we should do this for segments. In fact we should be looking at not shipping clrgc.dll given that regions have been live for 3+ releases already |
I think we should still maintain this path for two reasons:
The fix itself is small and straightforward — it passes the large page config as an integer through |
|
is the x86 case broken due to the new changes here? |
No, x86 is good:
|
|
@cshung, I'd prefer disabling the large page emulation for segments instead. As Manish mentioned, we only use segments mode on 32 bit systems and as you've also mentioned, for those, the large pages are not enabled and don't make sense. The emulated large pages are a great tool for testing large pages during GC development and in the PR, but I don't see it as something customers should use. So this mode really seems to have benefit only when regions are enabled. |
I think this is the right fix, but if we wanted to simply disable the test, I am happy with that too. Without this test though, segments + 64 bits + large page is functional but untested. That being said, it is a niche scenario, and it is just what it was, we didn't make it worse. |
I didn't mean disabling the test, but rather disabling emulated large pages support for the segments. |
Change virtual_alloc to accept an integer large_pages_config parameter (0=none, 1=real large pages, 2=emulation) instead of a boolean. When config=2, use VirtualReserve followed by VirtualCommit to emulate large page behavior without requiring OS large page privileges. Update the test to use per-object-heap hard limits which are required for the segments path with large pages.
This reverts commit 0aaa427.
Large page emulation mode (GCLargePages=2) is not supported on the segments path. When emulation is requested on segments, silently disable large pages instead of crashing with a segfault due to memory being reserved but never committed. Real large pages (GCLargePages=1) continue to work on segments as before. Fixes dotnet#127668 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
c3a2874 to
973587c
Compare
|
/ba-g the failures are timeouts that happen in many if not all PRs, unrelated to this change. |
…th) (#127763) In the non-regions (segments) path, `GCLargePages=2` (emulation mode) was not handled by `virtual_alloc`. The function only had a `bool use_large_pages_p` parameter, so it could not distinguish between real large pages (`VirtualReserveAndCommitLargePages`) and emulation mode (which needs `VirtualReserve` + `VirtualCommit`). In emulation mode, memory was reserved but never committed, causing a segfault on access. **Fix:** Change `virtual_alloc` to accept an `int large_page_config` parameter: - `0` = no large pages (reserve only) - `1` = real large pages (`VirtualReserveAndCommitLargePages`) - `2` = emulation (`VirtualReserve` + `VirtualCommit`) The caller computes `large_page_config` once and passes it through `reserve_initial_memory`, eliminating the need for `reserve_initial_memory` to access the static `large_pages_emulation_mode_p` field. The test is updated to use per-object-heap hard limits (`GCHeapHardLimitSOH`/`LOH`/`POH`), which are required for the segments path with large pages since each segment is sized to the full hard limit (soh + loh + poh = 3x limit with a single combined `GCHeapHardLimit`). Fixes #127668 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
In the non-regions (segments) path,
GCLargePages=2(emulation mode) was not handled byvirtual_alloc. The function only had abool use_large_pages_pparameter, so it could not distinguish between real large pages (VirtualReserveAndCommitLargePages) and emulation mode (which needsVirtualReserve+VirtualCommit). In emulation mode, memory was reserved but never committed, causing a segfault on access.Fix: Change
virtual_allocto accept anint large_page_configparameter:0= no large pages (reserve only)1= real large pages (VirtualReserveAndCommitLargePages)2= emulation (VirtualReserve+VirtualCommit)The caller computes
large_page_configonce and passes it throughreserve_initial_memory, eliminating the need forreserve_initial_memoryto access the staticlarge_pages_emulation_mode_pfield.The test is updated to use per-object-heap hard limits (
GCHeapHardLimitSOH/LOH/POH), which are required for the segments path with large pages since each segment is sized to the full hard limit (soh + loh + poh = 3x limit with a single combinedGCHeapHardLimit).Fixes #127668