From dc74b8adfd8b2eb83823615297a429f54d424f90 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 3 Aug 2022 12:42:21 +0800 Subject: [PATCH] Using push/pop in all pragma pack pair to avoid potential padding bugs --- public/common/TracyProtocol.hpp | 4 ++-- public/common/TracyQueue.hpp | 4 ++-- public/common/TracySystem.cpp | 2 +- server/TracyEvent.hpp | 4 ++-- server/TracySortedVector.hpp | 4 ++-- server/TracyVarArray.hpp | 4 ++-- server/TracyVector.hpp | 4 ++-- server/TracyWorker.hpp | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/public/common/TracyProtocol.hpp b/public/common/TracyProtocol.hpp index 5e975538..104636c4 100644 --- a/public/common/TracyProtocol.hpp +++ b/public/common/TracyProtocol.hpp @@ -34,7 +34,7 @@ enum HandshakeStatus : uint8_t enum { WelcomeMessageProgramNameSize = 64 }; enum { WelcomeMessageHostInfoSize = 1024 }; -#pragma pack( 1 ) +#pragma pack( push, 1 ) // Must increase left query space after handling! enum ServerQuery : uint8_t @@ -133,7 +133,7 @@ struct BroadcastMessage enum { BroadcastMessageSize = sizeof( BroadcastMessage ) }; -#pragma pack() +#pragma pack( pop ) } diff --git a/public/common/TracyQueue.hpp b/public/common/TracyQueue.hpp index 81c24d4d..5d7d3f6b 100644 --- a/public/common/TracyQueue.hpp +++ b/public/common/TracyQueue.hpp @@ -122,7 +122,7 @@ enum class QueueType : uint8_t NUM_TYPES }; -#pragma pack( 1 ) +#pragma pack( push, 1 ) struct QueueThreadContext { @@ -745,7 +745,7 @@ struct QueueItem QueueFiberLeave fiberLeave; }; }; -#pragma pack() +#pragma pack( pop ) enum { QueueItemSize = sizeof( QueueItem ) }; diff --git a/public/common/TracySystem.cpp b/public/common/TracySystem.cpp index ba7e7ed4..f1407953 100644 --- a/public/common/TracySystem.cpp +++ b/public/common/TracySystem.cpp @@ -114,7 +114,7 @@ struct THREADNAME_INFO DWORD dwThreadID; DWORD dwFlags; }; -# pragma pack(pop) +# pragma pack( pop ) void ThreadNameMsvcMagic( const THREADNAME_INFO& info ) { diff --git a/server/TracyEvent.hpp b/server/TracyEvent.hpp index d63eb592..1439918e 100644 --- a/server/TracyEvent.hpp +++ b/server/TracyEvent.hpp @@ -18,7 +18,7 @@ namespace tracy { -#pragma pack( 1 ) +#pragma pack( push, 1 ) struct StringRef { @@ -663,7 +663,7 @@ struct ChildSample enum { ChildSampleSize = sizeof( ChildSample ) }; -#pragma pack() +#pragma pack( pop ) struct ThreadData diff --git a/server/TracySortedVector.hpp b/server/TracySortedVector.hpp index 39293d60..f157198f 100644 --- a/server/TracySortedVector.hpp +++ b/server/TracySortedVector.hpp @@ -7,7 +7,7 @@ namespace tracy { -#pragma pack( 1 ) +#pragma pack( push, 1 ) template> class SortedVector { @@ -118,7 +118,7 @@ private: uint32_t sortedEnd; }; -#pragma pack() +#pragma pack( pop ) enum { SortedVectorSize = sizeof( SortedVector ) }; diff --git a/server/TracyVarArray.hpp b/server/TracyVarArray.hpp index c2b5704b..83515794 100644 --- a/server/TracyVarArray.hpp +++ b/server/TracyVarArray.hpp @@ -16,7 +16,7 @@ namespace tracy { -#pragma pack( 1 ) +#pragma pack( push, 1 ) template class VarArray { @@ -56,7 +56,7 @@ private: uint32_t m_hash; const short_ptr m_ptr; }; -#pragma pack() +#pragma pack( pop ) enum { VarArraySize = sizeof( VarArray ) }; diff --git a/server/TracyVector.hpp b/server/TracyVector.hpp index 4d71e5f0..3ed9d5ef 100644 --- a/server/TracyVector.hpp +++ b/server/TracyVector.hpp @@ -19,7 +19,7 @@ namespace tracy { -#pragma pack( 1 ) +#pragma pack( push, 1 ) template class Vector { @@ -348,7 +348,7 @@ private: template struct VectorAdapterDirect { const T& operator()( const T& it ) const { return it; } }; template struct VectorAdapterPointer { const T& operator()( const short_ptr& it ) const { return *it; } }; -#pragma pack() +#pragma pack( pop ) enum { VectorSize = sizeof( Vector ) }; diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 185a16b3..854514b7 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -158,13 +158,13 @@ public: uint8_t inlineFrame; }; -#pragma pack( 1 ) +#pragma pack( push, 1 ) struct GhostKey { CallstackFrameId frame; uint8_t inlineFrame; }; -#pragma pack() +#pragma pack( pop ) struct GhostKeyHasher {