forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitb3e184a
committed
Fix erroneous Valgrind markings in AllocSetRealloc.
If asked to decrease the size of a large (>8K) palloc chunk,AllocSetRealloc could improperly change the Valgrind state of memorybeyond the new end of the chunk: it would mark data UNDEFINED as faras the old end of the chunk after having done the realloc(3) call,thus tromping on the state of memory that no longer belongs to it.One would normally expect that memory to now be marked NOACCESS,so that this mislabeling might prevent detection of later errors.If realloc() had chosen to move the chunk someplace else (unlikely,but well within its rights) we could also mismark perfectly-validDEFINED data as UNDEFINED, causing false-positive valgrind reportslater. Also, any malloc bookkeeping data placed within this areamight now be wrongly marked, causing additional problems.Fix by replacing relevant uses of "oldsize" with "Min(size, oldsize)".It's sufficient to mark as far as "size" when that's smaller, becausewhatever remains in the new chunk size will be marked NOACCESS below,and we expect realloc() to have taken care of marking the memorybeyond the new official end of the chunk.While we're here, also rename the function's "oldsize" variableto "oldchksize" to more clearly explain what it actually holds,namely the distance to the end of the chunk (that is, requested sizeplus trailing padding). This is more consistent with the use of"size" and "chksize" to hold the new requested size and chunk size.Add a new variable "oldsize" in the one stanza where we're actuallytalking about the old requested size.Oversight in commitc477f3e. Back-patch to all supported branches,as that was, just in case anybody wants to do valgrind testing on backbranches.Karina LitskevichDiscussion:https://postgr.es/m/CACiT8iaAET-fmzjjZLjaJC4zwSJmrFyL7LAdHwaYyjjQOQ4hcg@mail.gmail.com1 parenta1f45f6 commitb3e184a
1 file changed
+33
-20
lines changedLines changed: 33 additions & 20 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1112 | 1112 |
| |
1113 | 1113 |
| |
1114 | 1114 |
| |
1115 |
| - | |
| 1115 | + | |
1116 | 1116 |
| |
1117 | 1117 |
| |
1118 | 1118 |
| |
| |||
1140 | 1140 |
| |
1141 | 1141 |
| |
1142 | 1142 |
| |
1143 |
| - | |
| 1143 | + | |
1144 | 1144 |
| |
1145 | 1145 |
| |
1146 | 1146 |
| |
1147 |
| - | |
| 1147 | + | |
1148 | 1148 |
| |
1149 | 1149 |
| |
1150 | 1150 |
| |
| |||
1187 | 1187 |
| |
1188 | 1188 |
| |
1189 | 1189 |
| |
1190 |
| - | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
1191 | 1195 |
| |
1192 | 1196 |
| |
1193 | 1197 |
| |
1194 |
| - | |
| 1198 | + | |
1195 | 1199 |
| |
1196 | 1200 |
| |
1197 |
| - | |
1198 |
| - | |
1199 |
| - | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
1200 | 1207 |
| |
1201 | 1208 |
| |
1202 |
| - | |
| 1209 | + | |
1203 | 1210 |
| |
1204 |
| - | |
| 1211 | + | |
| 1212 | + | |
1205 | 1213 |
| |
1206 | 1214 |
| |
1207 | 1215 |
| |
| |||
1211 | 1219 |
| |
1212 | 1220 |
| |
1213 | 1221 |
| |
1214 |
| - | |
1215 |
| - | |
1216 |
| - | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
1217 | 1228 |
| |
1218 |
| - | |
| 1229 | + | |
1219 | 1230 |
| |
1220 | 1231 |
| |
1221 | 1232 |
| |
| |||
1240 | 1251 |
| |
1241 | 1252 |
| |
1242 | 1253 |
| |
1243 |
| - | |
| 1254 | + | |
1244 | 1255 |
| |
1245 | 1256 |
| |
1246 | 1257 |
| |
1247 |
| - | |
| 1258 | + | |
1248 | 1259 |
| |
1249 | 1260 |
| |
1250 | 1261 |
| |
| |||
1255 | 1266 |
| |
1256 | 1267 |
| |
1257 | 1268 |
| |
1258 |
| - | |
| 1269 | + | |
1259 | 1270 |
| |
1260 | 1271 |
| |
1261 | 1272 |
| |
| |||
1278 | 1289 |
| |
1279 | 1290 |
| |
1280 | 1291 |
| |
1281 |
| - | |
| 1292 | + | |
1282 | 1293 |
| |
1283 | 1294 |
| |
1284 |
| - | |
| 1295 | + | |
1285 | 1296 |
| |
1286 | 1297 |
| |
1287 | 1298 |
| |
| |||
1290 | 1301 |
| |
1291 | 1302 |
| |
1292 | 1303 |
| |
1293 |
| - | |
| 1304 | + | |
1294 | 1305 |
| |
1295 | 1306 |
| |
1296 | 1307 |
| |
| |||
1313 | 1324 |
| |
1314 | 1325 |
| |
1315 | 1326 |
| |
| 1327 | + | |
1316 | 1328 |
| |
1317 | 1329 |
| |
1318 | 1330 |
| |
| |||
1337 | 1349 |
| |
1338 | 1350 |
| |
1339 | 1351 |
| |
| 1352 | + | |
1340 | 1353 |
| |
1341 | 1354 |
| |
1342 | 1355 |
| |
|
0 commit comments
Comments
(0)