Skip to content

[release/10.0] Fix startup segfault on linux-bionic-arm64 - #137631

Open
AntonLapounov wants to merge 1 commit into
dotnet:release/10.0from
AntonLapounov:fix_111071
Open

AntonLapounov wants to merge 1 commit into
dotnet:release/10.0from
AntonLapounov:fix_111071

Conversation

@AntonLapounov

Copy link
Copy Markdown
Contributor

Fixes a startup segfault on linux-bionic-arm64.

The same issue was fixed in main as part of feature change #119683. This PR applies only the one-line buffer-size fix.

Customer Impact

Applications targeting linux-bionic-arm64 segfault 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 the parse_properties function in monovm.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 0xb4 tag). 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_properties in monovm.c does not consume this property in .NET 8, so applications targeting linux-bionic-arm64 are not affected there.

Testing

Reproduced the crash and verified the fix on a Pixel 10 Pro running Android 16, using a linux-bionic-arm64 console application built with .NET 10.

Risk

Low. The change increases the stack buffer size by one character. The snwprintf call already uses ARRAY_SIZE, so it automatically picks up the new size. Behavior is unchanged for pointers that already fit in the existing buffer.

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
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Nov 16, 2026
@azure-pipelines

Copy link
Copy Markdown
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.

@AntonLapounov

Copy link
Copy Markdown
Contributor Author

@vitek-karas Please consider this fix for 10.0.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Host community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant