microsoft / microsoft/win32metadata
Suspicious duplicate structs that differ in architecture and pack only
- Dominant language
- C++
- Stars
- 1.5k
- Forks
- 149
- Avg merge
- 5d 16h
- Merged PRs (30d)
- 4
Description
I was ivestigating the underlying issue for https://github.com/microsoft/CsWin32/issues/1617#issuecomment-3833225127. It turned out metadata defines 2 nearly identical `RASDIALPARAMSW` structs which differs only in supported architecture and pack size:
```diff
.class public sequential ansi sealed beforefieldinit Windows.Win32.NetworkManagement.Rras.RASDIALPARAMSW
extends [netstandard]System.ValueType
{
.custom instance void [Windows.Win32.winmd]Windows.Win32.Foundation.Metadata.UnicodeAttribute::.ctor() = (
01 00 00 00
)
.custom instance void [Windows.Win32.winmd]Windows.Win32.Foundation.Metadata.SupportedArchitectureAttribute::.ctor(valuetype [Windows.Win32.winmd]Windows.Win32.Foundation.Metadata.Architecture) = (
+ 01 00 06 00 00 00 00 00 // X64 | Arm64
- 01 00 01 00 00 00 00 00 // X86
)
+ .pack 4
+ .size 0
// Fields
.field public uint32 dwSize
.field public char[0...256] szEntryName
.field public char[0...128] szPhoneNumber
.field public char[0...128] szCallbackNumber
.field public char[0...256] szUserName
.field public char[0...256] szPassword
.field public char[0...15] szDomain
.field public uint32 dwSubEntry
.field public native uint dwCallbackId
.field public uint32 dwIfIndex
.field public valuetype [Windows.Win32.winmd]Windows.Win32.Foundation.PWSTR szEncPassword
} // end of class Windows.Win32.NetworkManagement.Rras.RASDIALPARAMSW
```
This seems suspicious. The struct has nothing to do with memory or any other hardware access, so it seems wrong that it is emitted as architecture-specific. I am not an expert in such low-level stuff as memory alignment on different architectures, but I have a suspicion that on x86 `.pack 4` is a default value, so it isn't emitted explicitly and that makes the wrong split later on. If true, both definitions can be collapsed into a single one without need for architecture-specific structs. I would like to either confirm or deny my suspicion
Contributor guide
Research direction
Start by examining the architecture-specific metadata definitions for RASDIALPARAMSW and the related investigation in microsoft/CsWin32 issue 1617. Verify how packing defaults are represented for x86 versus x64 and Arm64; the issue is done when the suspected cause is confirmed or denied and the appropriate metadata change is identified.
Written by the indexing model from the issue text.
Assessment
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100