Repository navigation
Fix PropVariant overwriting the next object on heap - #28186
Open
Martin Costello (martincostello) wants to merge 3 commits into
Open
Martin Costello (martincostello) wants to merge 3 commits into
Martin Costello (martincostello) wants to merge 3 commits into
Conversation
`PropVariant` has 16 bytes of data but is passed to `PropVariantClear` as a 24 byte native `PROPVARIANT`, so clearing it zeroed the header of the next object on the heap. This caused intermittent runtime crashes on startup when that object was a COM object (dotnet/runtime#131636). Add a field so the managed object is large enough, and a test that fails without it. Assisted-by: Claude Code <noreply@anthropic.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Martin Costello (martincostello)
marked this pull request as ready for review
October 12, 2026 13:42
Martin Costello (martincostello)
requested a review
from a team
as a code owner
October 12, 2026 13:42
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The layout correction addresses the root cause and is covered by a focused regression test.
0 open findings
What changed in this PR
Fixes heap corruption caused by undersized PropVariant interop layout.
Changes:
- Adds native-layout padding to prevent overwriting adjacent objects.
- Adds a Windows regression test for heap-header corruption.
| File | Description |
|---|---|
src/Microsoft.PowerShell.ConsoleHost/WindowsTaskbarJumpList/PropVariant.cs |
Makes the managed layout large enough for native clearing. |
test/xUnit/csharp/test_PropVariant.cs |
Verifies clearing does not corrupt an adjacent object. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
4 of 9 tasks
Update the P/Invoke declaration to match the native API structure shapes explicitly.
- Remove test. - Fix build on macOS and Linux. - Resolve CodeFactor suggestions.
Ilya (iSazonov)
approved these changes
Oct 13, 2026
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.
PR Summary
PropVarianthas 16 bytes of data but is passed toPropVariantClearas a 24 byte nativePROPVARIANT, so clearing it zeroed the header of the next object on the heap. This caused intermittent runtime crashes on startup when that object was a COM object (dotnet/runtime#131636). Add a field so the managed object is large enough, and a test that fails without it.PR Context
Fixes dotnet/runtime#131636.
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header