Skip to content

Test failure: GC stress assertion (GetComponentSize() <= 2) || IsArray() in methodtable.cpp on x64 (Loader explicit-layout objrefandnonobjrefoverlap/case1) #129546

Description

@JulieLeeMSFT

Summary:
Under gcstress0x3 on x64, the Loader explicit-layout negative test objrefandnonobjrefoverlap/case1 (which expects a System.TypeLoadException because MyUnion2 overlaps an object field with a non-object field) aborts: while that expected exception propagates, a GC stackwalk validates an object whose MethodTable is inconsistent and trips (GetComponentSize() <= 2) || IsArray() at vm/methodtable.cpp:6304 (exit code -1073740286 instead of the expected 100).

Build Information:

Error Message:

15:13:05.456 Running test: Loader/classloader/explicitlayout/objrefandnonobjrefoverlap/case1/case1.dll
System.TypeLoadException: Could not load type 'MyUnion2' from assembly 'case1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' because it contains an object field at offset 0 that is incorrectly aligned or overlapped by a non-object field.
   at Test.Go()
   at Test.TestEntryPoint()

Assert failure(PID 9684 [0x000025d4], Thread: 4488 [0x1188]): (GetComponentSize() <= 2) || IsArray()

CORECLR! MethodTable::SanityCheck + 0x39 (0x00007ffc`00750a29)
CORECLR! MethodTable::Validate + 0xE (0x00007ffc`00753efe)
CORECLR! Object::ValidateInner + 0x119 (0x00007ffc`00764e99)
CORECLR! Object::Validate + 0xB0 (0x00007ffc`00764d40)
CORECLR! TGcInfoDecoder<AMD64GcInfoEncoding>::ReportStackSlotToGC + 0x165 (0x00007ffc`00c15c35)
CORECLR! TGcInfoDecoder<AMD64GcInfoEncoding>::EnumerateLiveSlots + 0x185D (0x00007ffc`00c111ad)
CORECLR! EECodeManager::EnumGcRefs + 0x2E7 (0x00007ffc`0060f737)
CORECLR! GcStackCrawlCallBack + 0x34B (0x00007ffc`0093f15b)
CORECLR! Thread::StackWalkFramesEx + 0x1FE (0x00007ffc`007cb5ae)
CORECLR! Thread::StackWalkFrames + 0x1D1 (0x00007ffc`007cb381)
    File: D:\a\_work\1\s\src\coreclr\vm\methodtable.cpp:6304
    Image: C:\h\w\B78609C9\p\corerun.exe

Exit Code: -1073740286
Expected: 100
Actual: -1073740286
END EXECUTION - FAILED

Affected test legs:

runtime-coreclr gcstress0x3-gcstress0xc
- coreclr windows x64 Checked gcstress0xc @ Windows.10.Amd64.Open
    - Loader.0.3

Console log: Console Log

Source: runtime-coreclr gcstress0x3-gcstress0xc / coreclr windows x64 Checked gcstress0xc @ Windows.10.Amd64.Open / Loader.0.3

Analysis:
The test case1.dll deliberately loads an explicit-layout struct (MyUnion2) that overlaps an object field with a non-object field, so a System.TypeLoadException is expected. Under GC stress, a stackwalk (Thread::StackWalkFrames -> EECodeManager::EnumGcRefs -> Object::Validate -> MethodTable::Validate -> SanityCheck) runs while this type is in a half-loaded/invalid state and asserts (GetComponentSize() <= 2) || IsArray() at src/coreclr/vm/methodtable.cpp:6304, aborting the process (exit -1073740286). This is a closely-related sibling of the object.cpp:548 !CREATE_CHECK_STRING(pMT && pMT->Validate()) assert seen in the other Loader work items (Loader.1.3/2.3/LoaderClassloaderGenerics) — both are GC object/MethodTable validation tripping on a mid-failed-load type under gcstress — but the verbatim assert site differs.

Related issues:

Milestone: 11.0.0

Note

This issue was generated with assistance from GitHub Copilot (AI).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status
    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions