Skip to content

Commit 5384105

Browse files
Reenable class-memaccess warning (#74363)
* Reenable class-memaccess warning * Match x64 logic in emitarm.cpp * Make GCProtect sections with "gc" variable consistent Co-authored-by: Jan Kotas <jkotas@microsoft.com>
1 parent 8755447 commit 5384105

56 files changed

Lines changed: 262 additions & 296 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

eng/native/configurecompiler.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,6 @@ if (CLR_CMAKE_HOST_UNIX)
451451
add_compile_options(-Wno-uninitialized)
452452
add_compile_options(-Wno-strict-aliasing)
453453
add_compile_options(-Wno-array-bounds)
454-
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-class-memaccess>)
455454
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-misleading-indentation>)
456455
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-stringop-overflow>)
457456
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-restrict>)

src/coreclr/classlibnative/bcltype/system.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,12 @@ void SystemNative::GenericFailFast(STRINGREF refMesgString, EXCEPTIONREF refExce
162162
EXCEPTIONREF refExceptionForWatsonBucketing;
163163
STRINGREF refErrorSourceString;
164164
} gc;
165-
ZeroMemory(&gc, sizeof(gc));
166-
167-
GCPROTECT_BEGIN(gc);
168-
169165
gc.refMesgString = refMesgString;
170166
gc.refExceptionForWatsonBucketing = refExceptionForWatsonBucketing;
171167
gc.refErrorSourceString = refErrorSourceString;
172168

169+
GCPROTECT_BEGIN(gc);
170+
173171
// Managed code injected FailFast maps onto the unmanaged version
174172
// (EEPolicy::HandleFatalError) in the following manner: the exit code is
175173
// always set to COR_E_FAILFAST and the address passed (usually a failing

src/coreclr/debug/daccess/request.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2892,7 +2892,7 @@ ClrDataAccess::GetOOMStaticData(struct DacpOomData *oomData)
28922892

28932893
SOSDacEnter();
28942894

2895-
memset(oomData, 0, sizeof(DacpOomData));
2895+
*oomData = {};
28962896

28972897
if (!GCHeapUtilities::IsServerHeap())
28982898
{
@@ -2921,7 +2921,7 @@ ClrDataAccess::GetOOMData(CLRDATA_ADDRESS oomAddr, struct DacpOomData *data)
29212921
return E_INVALIDARG;
29222922

29232923
SOSDacEnter();
2924-
memset(data, 0, sizeof(DacpOomData));
2924+
*data = {};
29252925

29262926
if (!GCHeapUtilities::IsServerHeap())
29272927
hr = E_FAIL; // doesn't make sense to call this on WKS mode
@@ -2974,7 +2974,7 @@ ClrDataAccess::GetGCInterestingInfoStaticData(struct DacpGCInterestingInfoData *
29742974
static_assert_no_msg(DAC_MAX_GC_MECHANISM_BITS_COUNT == MAX_GC_MECHANISM_BITS_COUNT);
29752975

29762976
SOSDacEnter();
2977-
memset(data, 0, sizeof(DacpGCInterestingInfoData));
2977+
*data = {};
29782978

29792979
if (g_heap_type != GC_HEAP_SVR)
29802980
{
@@ -3007,7 +3007,7 @@ ClrDataAccess::GetGCInterestingInfoData(CLRDATA_ADDRESS interestingInfoAddr, str
30073007
return E_INVALIDARG;
30083008

30093009
SOSDacEnter();
3010-
memset(data, 0, sizeof(DacpGCInterestingInfoData));
3010+
*data = {};
30113011

30123012
if (!GCHeapUtilities::IsServerHeap())
30133013
hr = E_FAIL; // doesn't make sense to call this on WKS mode

src/coreclr/debug/daccess/request_common.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ HeapTableIndex(DPTR(unused_gc_heap**) heaps, size_t index)
4444

4545
// field_offset = g_gcDacGlobals->gc_heap_field_offsets
4646
// p_field_offset = field_offset[field_index]
47-
// p_field = BASE + p_field_offset
47+
// p_field = BASE + p_field_offset
4848
// field_index++
4949
#define LOAD_BASE(field_name, field_type) \
5050
DPTR(int) p_##field_name##_offset = TableIndex(field_offsets, field_index, sizeof(int)); \
@@ -114,8 +114,7 @@ inline bool IsRegionGCEnabled()
114114
inline dac_gc_heap
115115
LoadGcHeapData(TADDR heap)
116116
{
117-
dac_gc_heap result;
118-
memset(&result, 0, sizeof(dac_gc_heap));
117+
dac_gc_heap result = {};
119118

120119
DPTR(int) field_offsets = g_gcDacGlobals->gc_heap_field_offsets;
121120
int field_index = 0;
@@ -163,9 +162,7 @@ inline void EnumGcHeap(TADDR heap)
163162
inline dac_generation
164163
LoadGeneration(TADDR generation)
165164
{
166-
dac_generation result;
167-
memset(&result, 0, sizeof(dac_generation));
168-
165+
dac_generation result = {};
169166
DPTR(int) field_offsets = g_gcDacGlobals->generation_field_offsets;
170167
int field_index = 0;
171168

src/coreclr/debug/di/dbgtransportmanager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
DbgTransportTarget *g_pDbgTransportTarget = NULL;
1414

1515
DbgTransportTarget::DbgTransportTarget()
16+
: m_pProcessList{}
17+
, m_sLock{}
1618
{
17-
memset(this, 0, sizeof(*this));
1819
}
1920

2021
// Initialization routine called only by the DbgTransportManager.

src/coreclr/debug/ee/controller.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ void ControllerStackInfo::SetReturnFrameWithActiveFrame()
368368

369369
// Invalidate the active frame.
370370
m_activeFound = false;
371-
memset(&(m_activeFrame), 0, sizeof(m_activeFrame));
371+
m_activeFrame = {};
372372
m_activeFrame.fp = LEAF_MOST_FRAME;
373373
}
374374

src/coreclr/debug/ee/funceval.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3301,7 +3301,7 @@ static void DoNormalFuncEval( DebuggerEval *pDE,
33013301
ThrowHR(COR_E_OVERFLOW);
33023302
}
33033303
FuncEvalArgInfo * pFEArgInfo = (FuncEvalArgInfo *)_alloca(cbAllocSize);
3304-
memset(pFEArgInfo, 0, cbAllocSize);
3304+
*pFEArgInfo = {};
33053305

33063306
GatherFuncEvalArgInfo(pDE, mSig, argData, pFEArgInfo);
33073307

@@ -3483,7 +3483,7 @@ static void GCProtectArgsAndDoNormalFuncEval(DebuggerEval *pDE,
34833483
ThrowHR(COR_E_OVERFLOW);
34843484
}
34853485
OBJECTREF * pObjectRefArray = (OBJECTREF*)_alloca(cbAllocSize);
3486-
memset(pObjectRefArray, 0, cbAllocSize);
3486+
*pObjectRefArray = {};
34873487
GCPROTECT_ARRAY_BEGIN(*pObjectRefArray, pDE->m_argCount);
34883488

34893489
//

src/coreclr/debug/inc/dbgappdomain.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ struct AppDomainEnumerationIPCBlock
283283
pADInfo->FreeEntry();
284284

285285
#ifdef _DEBUG
286-
memset(pADInfo, 0, sizeof(AppDomainInfo));
286+
*pADInfo = {};
287287
#endif
288288

289289
// decrement the used slot count

src/coreclr/debug/inc/dbgtransportsession.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ class DbgTransportSession
305305
{
306306
public:
307307
// No real work done in the constructor. Use Init() instead.
308-
DbgTransportSession();
308+
DbgTransportSession() = default;
309309

310310
// Cleanup what is allocated/created in Init()
311311
~DbgTransportSession();
@@ -422,7 +422,7 @@ class DbgTransportSession
422422
// error is raised) and which incoming messages are valid.
423423
enum SessionState
424424
{
425-
SS_Closed, // No session and no attempt is being made to form one
425+
SS_Closed = 0, // No session and no attempt is being made to form one
426426
SS_Opening_NC, // Session is being formed but no connection is established yet
427427
SS_Opening, // Session is being formed, the low level connection is in place
428428
SS_Open, // Session is fully formed and normal transport messages can be sent and received

src/coreclr/debug/shared/dbgtransportsession.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@ DbgTransportSession *g_pDbgTransport = NULL;
3131
#include "ddmarshalutil.h"
3232
#endif // !RIGHT_SIDE_COMPILE
3333

34-
// No real work done in the constructor. Use Init() instead.
35-
DbgTransportSession::DbgTransportSession()
36-
{
37-
m_ref = 1;
38-
m_eState = SS_Closed;
39-
}
40-
4134
DbgTransportSession::~DbgTransportSession()
4235
{
4336
DbgTransportLog(LC_Proxy, "DbgTransportSession::~DbgTransportSession() called");
@@ -81,7 +74,7 @@ HRESULT DbgTransportSession::Init(DebuggerIPCControlBlock *pDCB, AppDomainEnumer
8174

8275
// Start with a blank slate so that Shutdown() on a partially initialized instance will only do the
8376
// cleanup necessary.
84-
memset(this, 0, sizeof(*this));
77+
*this = {};
8578

8679
// Because of the above memset the embedded classes/structs need to be reinitialized especially
8780
// the two way pipe; it expects the in/out handles to be -1 instead of 0.

0 commit comments

Comments
 (0)