Skip to content

bpo-33351: Correct struct packing in _tracemalloc.c #6761

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Add struct packing for pointer_t and fix struct packing under clang-cl for
frame_t.

Patch by Ethan Smith
13 changes: 10 additions & 3 deletions Modules/_tracemalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ static PyThread_type_lock tables_lock;

#define DEFAULT_DOMAIN 0

/* Pack the frame_t structure to reduce the memory footprint. */
/* Pack the pointer_t structure to reduce the memory footprint. */
#if defined(_MSC_VER)
#pragma pack(push, 4)
#endif
typedef struct
#ifdef __GNUC__
__attribute__((packed))
Expand All @@ -76,14 +79,18 @@ __attribute__((packed))
uintptr_t ptr;
unsigned int domain;
} pointer_t;
#ifdef _MSC_VER
#pragma pack(pop)
#endif

/* Pack the frame_t structure to reduce the memory footprint on 64-bit
architectures: 12 bytes instead of 16. */
#if defined(_MSC_VER)
#pragma pack(push, 4)
#endif
typedef struct
#ifdef __GNUC__
__attribute__((packed))
#elif defined(_MSC_VER)
#pragma pack(push, 4)
#endif
{
/* filename cannot be NULL: "<unknown>" is used if the Python frame
Expand Down