Skip to content

Commit

Permalink
Revert addition of padding at the start of BagHeader
Browse files Browse the repository at this point in the history
There was a bug in this code -- when we shrink a bag with
ResizeBag, the new space may only be a single word, so the type
and flags members of BagHeader must be in the first word.
  • Loading branch information
ChrisJefferson authored and fingolfin committed May 22, 2019
1 parent 9990060 commit 4afe06a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
8 changes: 2 additions & 6 deletions src/gasman.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,7 @@ static void CANARY_ALLOW_ACCESS_BAG(Bag bag)

BagHeader * header = BAG_HEADER(bag);
VALGRIND_MAKE_MEM_DEFINED(
(char *)header + sizeof(header->memory_canary_padding1),
sizeof(*header) - sizeof(header->memory_canary_padding1) -
sizeof(header->memory_canary_padding2));
header, sizeof(*header) - sizeof(header->memory_canary_padding));
}

// Reverse CANARY_ALL_ACCESS_BAG, making the masterpointer, bag contents and
Expand All @@ -488,9 +486,7 @@ static void CANARY_FORBID_ACCESS_BAG(Bag bag)

BagHeader * header = BAG_HEADER(bag);
VALGRIND_MAKE_MEM_NOACCESS(
(char *)header + sizeof(header->memory_canary_padding1),
sizeof(*header) - sizeof(header->memory_canary_padding1) -
sizeof(header->memory_canary_padding2));
header, sizeof(*header) - sizeof(header->memory_canary_padding));
}

// Mark all bags as accessible
Expand Down
7 changes: 1 addition & 6 deletions src/gasman.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ typedef UInt * * Bag;
**
*/
typedef struct {
#if defined(GAP_MEMORY_CANARY)
// The following variable is marked as not readable or writable
// in valgrind, to check for code reading before the start of the header.
uint64_t memory_canary_padding1[8];
#endif
uint8_t type : 8;
uint8_t flags : 8;
// the following unnamed field ensures that on 32 bit systems,
Expand All @@ -94,7 +89,7 @@ typedef struct {
#if defined(GAP_MEMORY_CANARY)
// The following variable is marked as not readable or writable
// in valgrind, to check for code reading before the start of a Bag.
uint64_t memory_canary_padding2[8];
uint64_t memory_canary_padding[8];
#endif
} BagHeader;

Expand Down

0 comments on commit 4afe06a

Please sign in to comment.