forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork0
Commitc6f7f11
committed
Fix edge-case resource leaks in PL/Python error reporting.
PLy_elog_impl and its subroutine PLy_traceback intended to avoidleaking any PyObject reference counts, but their coverage of thematter was sadly incomplete. In particular, out-of-memory errorsin most of the string-construction subroutines could lead toreference count leaks, because those calls were outside thePG_TRY blocks responsible for dropping reference counts.Fix by (a) adjusting the scopes of the PG_TRY blocks, and(b) moving the responsibility for releasing the reference countsof the traceback-stack objects to PLy_elog_impl. This requiressome additional "volatile" markers, but not too many.In passing, fix an ancient thinko: use of the "e_module_o" PyObjectwas guarded by "if (e_type_s)", where surely "if (e_module_o)"was meant. This would only have visible consequences if the"__name__" attribute were present but the "__module__" attributewasn't, which apparently never happens; but someday it might.Rearranging the PG_TRY blocks requires indenting a fair amountof code one more tab stop, which I'll do separately for clarity.Author: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/2954090.1748723636@sss.pgh.pa.usBackpatch-through: 131 parente5a3c9d commitc6f7f11
1 file changed
+55
-50
lines changedLines changed: 55 additions & 50 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
18 | 18 |
| |
19 | 19 |
| |
20 | 20 |
| |
21 |
| - | |
| 21 | + | |
| 22 | + | |
22 | 23 |
| |
23 | 24 |
| |
24 | 25 |
| |
| |||
43 | 44 |
| |
44 | 45 |
| |
45 | 46 |
| |
46 |
| - | |
47 |
| - | |
| 47 | + | |
| 48 | + | |
48 | 49 |
| |
49 | 50 |
| |
50 | 51 |
| |
51 | 52 |
| |
52 | 53 |
| |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
53 | 64 |
| |
54 | 65 |
| |
55 | 66 |
| |
| |||
62 | 73 |
| |
63 | 74 |
| |
64 | 75 |
| |
65 |
| - | |
66 |
| - | |
67 | 76 |
| |
68 | 77 |
| |
69 | 78 |
| |
| |||
81 | 90 |
| |
82 | 91 |
| |
83 | 92 |
| |
84 |
| - | |
85 | 93 |
| |
86 | 94 |
| |
87 | 95 |
| |
88 | 96 |
| |
89 | 97 |
| |
90 |
| - | |
91 | 98 |
| |
92 | 99 |
| |
93 | 100 |
| |
| |||
113 | 120 |
| |
114 | 121 |
| |
115 | 122 |
| |
116 |
| - | |
117 |
| - | |
118 | 123 |
| |
119 | 124 |
| |
120 | 125 |
| |
| |||
136 | 141 |
| |
137 | 142 |
| |
138 | 143 |
| |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
139 | 155 |
| |
140 | 156 |
| |
141 | 157 |
| |
142 | 158 |
| |
143 | 159 |
| |
144 | 160 |
| |
145 |
| - | |
146 |
| - | |
147 | 161 |
| |
148 | 162 |
| |
149 | 163 |
| |
| |||
154 | 168 |
| |
155 | 169 |
| |
156 | 170 |
| |
157 |
| - | |
158 |
| - | |
159 |
| - | |
160 | 171 |
| |
161 | 172 |
| |
162 | 173 |
| |
163 |
| - | |
| 174 | + | |
164 | 175 |
| |
165 |
| - | |
166 |
| - | |
167 |
| - | |
168 |
| - | |
169 |
| - | |
170 |
| - | |
171 |
| - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
172 | 179 |
| |
173 | 180 |
| |
174 | 181 |
| |
| |||
186 | 193 |
| |
187 | 194 |
| |
188 | 195 |
| |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
189 | 202 |
| |
190 | 203 |
| |
191 | 204 |
| |
192 | 205 |
| |
193 | 206 |
| |
194 |
| - | |
| 207 | + | |
195 | 208 |
| |
196 | 209 |
| |
197 | 210 |
| |
| |||
215 | 228 |
| |
216 | 229 |
| |
217 | 230 |
| |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
218 | 239 |
| |
219 | 240 |
| |
220 | 241 |
| |
221 | 242 |
| |
222 |
| - | |
223 | 243 |
| |
224 | 244 |
| |
225 | 245 |
| |
226 | 246 |
| |
227 | 247 |
| |
228 | 248 |
| |
229 |
| - | |
230 | 249 |
| |
231 | 250 |
| |
232 | 251 |
| |
| |||
254 | 273 |
| |
255 | 274 |
| |
256 | 275 |
| |
257 |
| - | |
258 |
| - | |
259 |
| - | |
260 |
| - | |
261 |
| - | |
262 |
| - | |
263 |
| - | |
264 |
| - | |
265 |
| - | |
266 |
| - | |
267 |
| - | |
268 | 276 |
| |
269 | 277 |
| |
270 | 278 |
| |
| |||
320 | 328 |
| |
321 | 329 |
| |
322 | 330 |
| |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
323 | 341 |
| |
324 |
| - | |
325 |
| - | |
326 |
| - | |
327 |
| - | |
328 |
| - | |
329 |
| - | |
330 |
| - | |
331 |
| - | |
| 342 | + | |
332 | 343 |
| |
333 |
| - | |
334 |
| - | |
335 | 344 |
| |
336 | 345 |
| |
337 | 346 |
| |
338 | 347 |
| |
339 | 348 |
| |
340 | 349 |
| |
341 | 350 |
| |
342 |
| - | |
343 |
| - | |
344 |
| - | |
345 |
| - | |
346 | 351 |
| |
347 | 352 |
| |
348 | 353 |
| |
|
0 commit comments
Comments
(0)