Repository navigation
[release/10.0] Fix startup segfault on linux-bionic-arm64 - #137631
Open
AntonLapounov wants to merge 1 commit into
Open
AntonLapounov wants to merge 1 commit into
AntonLapounov wants to merge 1 commit into
Conversation
The buffer for the formatted runtime contract pointer was 18 characters, sized without the terminating NUL, but a full 64-bit pointer formatted with "0x%zx" needs 19 bytes. snwprintf truncated the last hex digit, so the HOST_RUNTIME_CONTRACT property received the pointer shifted right by 4 bits. This only shows up when the pointer has 16 hex digits, such as heap pointers with a nonzero top byte on Android arm64 (0xb4 tag). The runtime then dereferenced the wrong address and crashed with SIGSEGV during startup. Size the buffer with + 1 for the terminator. Fixes dotnet#111071
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 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
Author
|
@vitek-karas Please consider this fix for 10.0. |
This was referenced Nov 16, 2026
This branch has not been deployed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes a startup segfault on
linux-bionic-arm64.The same issue was fixed in
mainas part of feature change #119683. This PR applies only the one-line buffer-size fix.Customer Impact
linux-bionic-arm64andandroid-arm64(.NET 9+) #117547Applications targeting
linux-bionic-arm64segfault at startup, before any managed code executes.The host formats the address of the runtime contract (
HOST_PROPERTY_RUNTIME_CONTRACT) into a buffer that is one character too small, truncating the last hexadecimal digit. As a result, the runtime receives a pointer value shifted right by 4 bits and dereferences an invalid address in theparse_propertiesfunction inmonovm.c.This occurs whenever the pointer requires 16 hexadecimal digits, as is the case for top-byte-tagged heap pointers on Android arm64 (for example, pointers with a
0xb4tag). Pointers on x64 and platforms without tagged pointers fit in the existing buffer and are unaffected.Regression
Yes. The issue was introduced in .NET 9 by #95801. The same off-by-one error also exists in .NET 8 (introduced by #97891), but
parse_propertiesinmonovm.cdoes not consume this property in .NET 8, so applications targetinglinux-bionic-arm64are not affected there.Testing
Reproduced the crash and verified the fix on a Pixel 10 Pro running Android 16, using a
linux-bionic-arm64console application built with .NET 10.Risk
Low. The change increases the stack buffer size by one character. The
snwprintfcall already usesARRAY_SIZE, so it automatically picks up the new size. Behavior is unchanged for pointers that already fit in the existing buffer.