Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit dfdd826

Browse files
Daniel PodderPetermarcu
authored andcommitted
Ensure that ZeroMemoryInGCHeap writes in pointer-sized increments (#12701)
by adding the volatile keyword (which disables memset optimization). Fixes #12207
1 parent e3ee3cd commit dfdd826

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/vm/object.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2954,8 +2954,9 @@ void __fastcall ZeroMemoryInGCHeap(void* mem, size_t size)
29542954
*memBytes++ = 0;
29552955

29562956
// now write pointer sized pieces
2957+
// volatile ensures that this doesn't get optimized back into a memset call (see #12207)
29572958
size_t nPtrs = (endBytes - memBytes) / sizeof(PTR_PTR_VOID);
2958-
PTR_PTR_VOID memPtr = (PTR_PTR_VOID) memBytes;
2959+
volatile PTR_PTR_VOID memPtr = (PTR_PTR_VOID) memBytes;
29592960
for (size_t i = 0; i < nPtrs; i++)
29602961
*memPtr++ = 0;
29612962

0 commit comments

Comments
 (0)