forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit210bece
committed
Fix some possibly latent bugs in slab.c
Primarily, this fixes an incorrect calculation in SlabCheck which waslooking in the wrong byte for the sentinel check. The reason that we'venever noticed this before in the form of a failing sentinel check isbecause the pre-check to this always fails because all current core usersof slab contexts have a chunk size which is already MAXALIGNed, thereforethere's never any space for the sentinel byte. It is possible that anextension needs to use a slab context and if they do with a chunk sizethat's not MAXALIGNed, then they'll likely get errors about overwrittensentinel bytes.Additionally, this patch changes various calculations which are being donebased on the sizeof(SlabBlock). Currently, sizeof(SlabBlock) is amultiple of 8, therefore sizeof(SlabBlock) is the same asMAXALIGN(sizeof(SlabBlock)), however, if we were to ever have to add anyfields to that struct as part of a bug fix, then SlabAlloc could end upreturning a non-MAXALIGNed pointer. To be safe, let's ensure we alwaysMAXALIGN sizeof(SlabBlock) before using it in any calculations.This patch has already been applied to master ind5ee4db.Diagnosed-by: Tomas Vondra, Tom LaneAuthor: Tomas Vondra, David RowleyDiscussion:https://postgr.es/m/CAA4eK1%2B1JyW5TiL%3DyV-3Uq1CrfnTyn0Xrk5uArt31Z%3D8rgPhXQ%40mail.gmail.comBackpatch-through: 101 parent5be9cff commit210bece
1 file changed
+8
-6
lines changedLines changed: 8 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
56 | 56 |
| |
57 | 57 |
| |
58 | 58 |
| |
| 59 | + | |
| 60 | + | |
59 | 61 |
| |
60 | 62 |
| |
61 | 63 |
| |
| |||
116 | 118 |
| |
117 | 119 |
| |
118 | 120 |
| |
119 |
| - | |
| 121 | + | |
120 | 122 |
| |
121 | 123 |
| |
122 |
| - | |
| 124 | + | |
123 | 125 |
| |
124 | 126 |
| |
125 | 127 |
| |
| |||
168 | 170 |
| |
169 | 171 |
| |
170 | 172 |
| |
171 |
| - | |
| 173 | + | |
172 | 174 |
| |
173 | 175 |
| |
174 | 176 |
| |
| |||
198 | 200 |
| |
199 | 201 |
| |
200 | 202 |
| |
201 |
| - | |
| 203 | + | |
202 | 204 |
| |
203 | 205 |
| |
204 | 206 |
| |
205 | 207 |
| |
206 |
| - | |
| 208 | + | |
207 | 209 |
| |
208 | 210 |
| |
209 | 211 |
| |
| |||
769 | 771 |
| |
770 | 772 |
| |
771 | 773 |
| |
772 |
| - | |
| 774 | + | |
773 | 775 |
| |
774 | 776 |
| |
775 | 777 |
| |
|
0 commit comments
Comments
(0)