Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/6.0] Disable poisoning for large structs #61601

Merged
merged 5 commits into from
Dec 15, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/coreclr/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12551,6 +12551,17 @@ void CodeGen::genPoisonFrame(regMaskTP regLiveIn)

assert(varDsc->lvOnFrame);

int size = (int)compiler->lvaLclSize(varNum);

if (size / TARGET_POINTER_SIZE > 16)
jakobbotsch marked this conversation as resolved.
Show resolved Hide resolved
{
// For very large structs the offsets in the movs we emit below can
// grow too large to be handled properly by JIT. Furthermore, while
// this is only debug code, for very large structs this can bloat
// the code too much due to the singular movs used.
continue;
}

if (!hasPoisonImm)
{
#ifdef TARGET_64BIT
Expand All @@ -12568,8 +12579,7 @@ void CodeGen::genPoisonFrame(regMaskTP regLiveIn)
#else
int addr = 0;
#endif
int size = (int)compiler->lvaLclSize(varNum);
int end = addr + size;
int end = addr + size;
for (int offs = addr; offs < end;)
{
#ifdef TARGET_64BIT
Expand Down
23 changes: 22 additions & 1 deletion src/tests/JIT/Directed/debugging/poison.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ public static unsafe int Main()
WithoutGCRef poisoned2;
Unsafe.SkipInit(out poisoned2);
result &= VerifyPoison(&poisoned2, sizeof(WithoutGCRef));

Massive poisoned3;
Unsafe.SkipInit(out poisoned3);
result &= VerifyPoison(&poisoned3, sizeof(Massive));

WithoutGCRef poisoned4;
Unsafe.SkipInit(out poisoned4);
result &= VerifyPoison(&poisoned4, sizeof(WithoutGCRef));

Massive poisoned5;
Unsafe.SkipInit(out poisoned5);
result &= VerifyPoison(&poisoned5, sizeof(Massive));

GCRef zeroed2;
Unsafe.SkipInit(out zeroed2);
result &= VerifyZero(Unsafe.AsPointer(ref zeroed2), Unsafe.SizeOf<GCRef>());

return result ? 100 : 101;
}
Expand Down Expand Up @@ -53,4 +69,9 @@ private struct WithoutGCRef
public int ANumber;
public float AFloat;
}
}

private unsafe struct Massive
{
public fixed byte Bytes[0x10008];
}
}