Skip to content

[release/10.0] Fix bug in LowerCallMemmove#125173

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/backport-fix-123907-to-release-10-0
Closed

[release/10.0] Fix bug in LowerCallMemmove#125173
Copilot wants to merge 2 commits intomainfrom
copilot/backport-fix-123907-to-release-10-0

Conversation

Copy link
Contributor

Copilot AI commented Mar 4, 2026

main PR #123907

Description

LowerCallMemmove handled CORINFO_HELP_MEMCPY by setting BlkOpKindUnroll on the newly constructed STORE_BLK, but then skipped re-lowering srcBlk/storeBlk entirely. This left the address nodes in an unlowered state, allowing them to become contained — violating the contract that genCodeForMemmove (and genCodeForCpBlkUnroll) rely on.

Fix: always use BlkOpKindUnrollMemmove for both memmove and memcpy paths. The nodes are hand-constructed already in their final lowered form, so genCodeForMemmove handles them correctly without a separate lowering pass.

  • assert(!dstAddr->isContained()) / assert(!srcAddr->isContained()) — enforces the invariant genCodeForMemmove relies on, and catches future regressions.
  • Remove conditional BlkOpKindUnroll — use BlkOpKindUnrollMemmove unconditionally; avoids the need to re-lower nodes created by this function.
  • Update comment — replaces misleading // TODO: This skips lowering srcBlk and storeBlk. with an accurate explanation.

Customer Impact

Unsafe.CopyBlockUnaligned / cpblk with a size that becomes constant in a late JIT phase can produce incorrect code on affected builds.

Regression

  • Yes
  • No

Present since CORINFO_HELP_MEMCPY handling was added to LowerCallMemmove.

Testing

Covered by the existing memmove/memcpy unrolling test suite. The original fix in main was validated with no jit-diffs (see PR #123907).

Risk

Low. Single-function change, logic simplification only — removes a conditional branch and adds debug-only assertions. The CORINFO_HELP_MEMCPY unroll path is rarely exercised (requires constant-length cpblk resolved in a late phase). BlkOpKindUnrollMemmove is already the well-tested code path for the memmove case.

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.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.

Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com>
Copilot AI changed the title [WIP] Backport fix from PR 123907 into release 10.0 branch [release/10.0] Fix bug in LowerCallMemmove Mar 4, 2026
@EgorBo EgorBo closed this Mar 4, 2026
@akoeplinger akoeplinger deleted the copilot/backport-fix-123907-to-release-10-0 branch March 4, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants