forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd5ee4db
committed
Use MAXALIGN() in calculations using sizeof(SlabBlock)
c6e0fe1 added a new pointer field to SlabBlock to make it 4 bytes largeron 32-bit machines. Prior to that commit, the size of that struct was amultiple of 8, which meant that MAXALIGN(sizeof(SlabBlock)) was the sameas sizeof(SlabBlock), however, afterc6e0fe1, due to the addition of thenew pointer field to store a pointer to the owning context, that was nolonger true on builds with sizeof(void *) == 4.This problem was highlighted by an Assert failure which was checking thatthe pointer given to pfree() was MAXALIGNED. Various 32-bit ARM buildfarmanimals were failing. These have MAXIMUM_ALIGNOF of 8. The only 32-bittesting I'd managed to do onc6e0fe1 had been on x86, which has aMAXIMUM_ALIGNOF of 4, therefore did not exhibit this issue.Here we define Slab_BLOCKHDRSZ and copy what is being done in aset.c andgeneration.c for doing calculations based on the size of the context'sblock type. This means that SlabAlloc() will now always return aMAXALIGNed pointer.This also fixes an incorrect sentinel_ok() check in SlabCheck() which wasincorrectly checking the wrong sentinel byte. This must have previouslynot caused any issues due to the fullChunkSize never being large enough tostore the sentinel byte.Diagnosed-by: Tomas Vondra, Tom LaneAuthor: Tomas Vondra, David RowleyDiscussion:https://postgr.es/m/CAA4eK1%2B1JyW5TiL%3DyV-3Uq1CrfnTyn0Xrk5uArt31Z%3D8rgPhXQ%40mail.gmail.com1 parentb1ec7f4 commitd5ee4db
1 file changed
+7
-5
lines changedLines changed: 7 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
58 | 58 |
| |
59 | 59 |
| |
60 | 60 |
| |
| 61 | + | |
| 62 | + | |
61 | 63 |
| |
62 | 64 |
| |
63 | 65 |
| |
| |||
102 | 104 |
| |
103 | 105 |
| |
104 | 106 |
| |
105 |
| - | |
| 107 | + | |
106 | 108 |
| |
107 | 109 |
| |
108 |
| - | |
| 110 | + | |
109 | 111 |
| |
110 | 112 |
| |
111 | 113 |
| |
| |||
146 | 148 |
| |
147 | 149 |
| |
148 | 150 |
| |
149 |
| - | |
| 151 | + | |
150 | 152 |
| |
151 | 153 |
| |
152 | 154 |
| |
153 | 155 |
| |
154 |
| - | |
| 156 | + | |
155 | 157 |
| |
156 | 158 |
| |
157 | 159 |
| |
| |||
744 | 746 |
| |
745 | 747 |
| |
746 | 748 |
| |
747 |
| - | |
| 749 | + | |
748 | 750 |
| |
749 | 751 |
| |
750 | 752 |
| |
|
0 commit comments
Comments
(0)