Skip to content

[release/10.0] Fix SampleProfilerSampleType overflow on 32-bit platforms - #136441

Open
github-actions[bot] wants to merge 2 commits into
release/10.0from
backport/pr-136433-to-release/10.0
Open

github-actions[bot] wants to merge 2 commits into
release/10.0from
backport/pr-136433-to-release/10.0

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Backport of #136433 to release/10.0

/cc @steveisok @pcshrosbree

Customer Impact

  • Customer reported
  • Found internally

[Select one or both of the boxes. Describe how this issue impacts customers, citing the expected and actual behaviors and scope of the issue. If customer-reported, provide the issue number.]

Regression

  • Yes
  • No

[If yes, specify when the regression was introduced. Provide the PR or commit if known.]

Testing

[How was the fix verified? How was the issue missed previously? What tests were added?]

Risk

[High/Medium/Low. Justify the indication by mentioning how risks were measured and addressed.]

IMPORTANT: If this backport is for a servicing release, please verify that:

  • For .NET 8 and .NET 9: The PR target branch is release/X.0-staging, not release/X.0.
  • For .NET 10+: The PR target branch is release/X.0 (no -staging suffix).

Package authoring no longer needed in .NET 9

IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version.
Keep in mind that we still need package authoring in .NET 8 and older versions.

TraceEvent stores the stack attachment pointer (StackBytes - 8) in
EVENT_HEADER_EXTENDED_DATA_ITEM.DataPtr through IntPtr's explicit
conversion to long, which sign-extends on 32-bit platforms. On
linux-arm, an attachment pointer at or above 0x80000000 therefore reads
back as 0xFFFFFFFF_xxxxxxxx, and the checked conversion to nuint in
RawEventPipeStack.Read throws OverflowException. Keep only the
native-width bits instead.

The fixed test has not been run on linux-arm; validation so far covers
the conversion arithmetic and the IL on x64.

Fixes #136197
@azure-pipelines

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

Apply jkotas review feedback without changing the truncating native-width conversion.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
steveisok added a commit that referenced this pull request Oct 25, 2026
<!-- -->

## Summary

Apply [Jan's review
feedback](#136440 (comment))
on the backport of #136433: use `IntPtr stack = (nint)address;`, since
`IntPtr` and `nint` are the same type.

This is a one-line, test-only syntax cleanup. The existing
sign-extension comment, `ulong` address representation, and
stack-reading logic are unchanged. The project uses unchecked arithmetic
by default, so the truncating native-width conversion is preserved. The
crash fix is already in #136433; this follow-up does not independently
fix it.

The same correction has been pushed to the existing release/11.0
backport #136440 (`14b7ddd4f5ba5d5af35afc23e916be80d3d0b9e1`) and
release/10.0 backport #136441
(`d5ce4c1d541740525d038b0b30988058edfe2a89`; helper is in `GCEvents.cs`
there).

## Validation

- Evaluated the actual test projects with installed MSBuild on all three
branches: `CheckForOverflowUnderflow=false` for ARM and ARM64 in Debug,
Checked, and Release. There is no enclosing checked block around the
cast.
- Built and ran a standalone cast-equivalence probe on ARM64 with .NET
10.0.9 and .NET 11.0.0-preview.6.26322.101. Each run passed 10
native-width vectors and 10 simulated 32-bit narrowing vectors,
including the sign-extended high-bit pointer `0xFFFFFFFFD2345678`.
- Old and simplified native casts emit identical IL: `ldarg.0; conv.i;
ret`. A checked-conversion control throws as expected.
- `git diff --check` passed on all three branches.

No full runtime rebuild or EventPipe test-harness run was performed. The
32-bit checks were simulated narrowing on ARM64, not actual ARM32
execution. The standalone probe is not part of the PR.

> [!NOTE]
> This PR description and change were prepared with GitHub Copilot.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants