Commit 7706f54
[release/10.0] Fix bug in LowerCallMemmove (#125175)
Backport of #123907 to
release/10.0 to fix #123748
/cc @EgorBo
## Customer Impact
- [x] Customer reported
- [ ] Found internally
JIT crashes with an access violation (0xC0000005) when compiling calls
to C++/CLI functions returning structs with aggregate initialization.
The crash occurs in `LowerCallMemmove` during JIT compilation because
`BlkOpKindUnroll` was used for `CORINFO_HELP_MEMCPY`, which bypasses the
memmove-aware lowering paired with `genCodeForMemmove`. This leads to
contained address nodes being passed where non-contained nodes are
expected, causing the null dereference.
## Regression
- [x] Yes
- [ ] No
## Fix
Use `BlkOpKindUnrollMemmove` uniformly for both `Memmove` and `MEMCPY`
helpers. While slightly more expensive for LSRA (no addressing modes),
`CORINFO_HELP_MEMCPY` is rarely used, so the impact is negligible. Also
adds asserts to catch contained address nodes early.
## Testing
No diffs in [SPMI
replay](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1287687&view=ms.vss-build-web.run-extensions-tab).
Verified on main via PR #123907.
## Risk
Low. The change makes memcpy use the same safe code path as memmove,
which is already well-tested. The only behavioral difference is slightly
different register allocation for the rare `CORINFO_HELP_MEMCPY` case.
Co-authored-by: egorbot <egorbot@egorbo.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 984dd1d commit 7706f54
1 file changed
+6
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2448 | 2448 | | |
2449 | 2449 | | |
2450 | 2450 | | |
| 2451 | + | |
| 2452 | + | |
2451 | 2453 | | |
2452 | 2454 | | |
2453 | 2455 | | |
| |||
2457 | 2459 | | |
2458 | 2460 | | |
2459 | 2461 | | |
2460 | | - | |
2461 | | - | |
2462 | | - | |
2463 | | - | |
| 2462 | + | |
| 2463 | + | |
2464 | 2464 | | |
2465 | 2465 | | |
2466 | 2466 | | |
| |||
2478 | 2478 | | |
2479 | 2479 | | |
2480 | 2480 | | |
2481 | | - | |
| 2481 | + | |
| 2482 | + | |
2482 | 2483 | | |
2483 | 2484 | | |
2484 | 2485 | | |
| |||
0 commit comments