Repository navigation
Conversation
…net#136265) Fixes dotnet#136201. Initialize the Unix GS cookie before registering the lazy runtime initialization callback, and query the page size independently of GC initialization. Add coverage for a first export call with a stack-allocated buffer. --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Copilot Autofix powered by AI <[email protected]> Copilot-Session: 417e95b3-e5d3-40a0-b723-4f2b70693851 (cherry picked from commit 53ac1a9)
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
Member
|
This backport does not meet the servicing bar for .NET 8 . https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core |
This was referenced Oct 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #136265 to
release/8.0-staging.Related customer report: #136201.
Description
Initialize the Unix NativeAOT shared-library GS cookie before publishing the lazy runtime initialization callback. Otherwise the first managed export can save the initial zero cookie in its prologue, initialize the runtime (and change the cookie), then fail the cookie check in its epilogue.
Retain the executable initialization path and the regression test that calls an export with a stack-allocated buffer before any other managed export.
Branch-specific adaptations:
Runtime/unix/PalRedhawkUnix.cpp, the .NET 8 Unix PAL implementation, rather than adding the newerPalUnix.cppfile.sysconf(_SC_PAGE_SIZE)inPalVirtualProtect, following the existing Unix PAL page-size query. This branch does not containminipal/ospagesize.h; page-size lookup must not depend on GC/runtime initialization.PalGetModuleHandleFromPointersignature, debug-header population, thunk-pool lock initialization, and reverse-P/Invoke implementation.new Type[]syntax for export calling conventions. Do not bring in the unrelated module-initializer test from newer branches.Customer Impact
Customer-reported NativeAOT shared libraries on linux-x64 abort the process (exit 134) when their first export call has a GS-protected frame, such as a
stackallocor a struct containing a fixed buffer. The report reproduces this with .NET 8.0.32, as well as newer versions.Calling a different export first or moving the buffer into a separate non-inlined method can avoid the reported crash, but requires callers or library authors to know about the initialization-order issue.
.NET 8 is close to end of support; please consider whether this can still be included in remaining servicing.
Regression
No known recent servicing regression. The report reproduces the problem on .NET 8, 9, 10, and 11 RC2.
Testing
git diff --checkpassed.Risk
Low-to-moderate. This is a narrow backport of the reviewed mainline fix, but it changes Unix shared-library initialization and memory protection before normal runtime initialization. The page-size query is made independent of GC initialization, and executable cookie initialization remains explicit. The Unix initialization path and shared-library smoke test need CI coverage; Windows behavior should remain unchanged.
Package authoring
No library-package project changes are included: this fix is in the NativeAOT runtime and its smoke test. Please advise if any additional .NET 8 servicing packaging changes are required.
/cc @MichalStrehovsky @agocke
Prepared with assistance from GitHub Copilot.