forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit0162a9b
committed
Remove race conditions between ECPGdebug() and ecpg_log().
Coverity complains that ECPGdebug is accessing debugstream withoutholding debug_mutex, which is a fair complaint: we should takedebug_mutex while changing the settings ecpg_log looks at.In some branches it also complains about unlocked use of simple_debug.I think it's intentional and safe to have a quick unlocked check ofsimple_debug at the start of ecpg_log, since that early exit willalways be taken in non-debug cases. But we should rechecksimple_debug after acquiring the mutex. In the worst case, callingECPGdebug concurrently with ecpg_log in another thread could resultin a null-pointer dereference due to debugstream transiently beingNULL while simple_debug isn't 0.This is largely hypothetical, since it's unlikely anybody usesECPGdebug() at all in the field, and our own regression testsdon't seem to be hitting the theoretical race conditions either.Still, if we're going to the trouble of having mutexes here, we oughtto be using them in a way that's actually safe not just almost safe.Hence, back-patch to all supported branches.1 parentda32f5c commit0162a9b
1 file changed
+28
-11
lines changedLines changed: 28 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
60 | 60 |
| |
61 | 61 |
| |
62 | 62 |
| |
63 |
| - | |
| 63 | + | |
64 | 64 |
| |
65 | 65 |
| |
66 | 66 |
| |
| |||
203 | 203 |
| |
204 | 204 |
| |
205 | 205 |
| |
| 206 | + | |
206 | 207 |
| |
207 | 208 |
| |
| 209 | + | |
| 210 | + | |
| 211 | + | |
208 | 212 |
| |
209 | 213 |
| |
210 | 214 |
| |
| |||
215 | 219 |
| |
216 | 220 |
| |
217 | 221 |
| |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
218 | 226 |
| |
219 | 227 |
| |
220 | 228 |
| |
| |||
229 | 237 |
| |
230 | 238 |
| |
231 | 239 |
| |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
232 | 245 |
| |
233 | 246 |
| |
234 | 247 |
| |
| |||
251 | 264 |
| |
252 | 265 |
| |
253 | 266 |
| |
254 |
| - | |
255 |
| - | |
256 |
| - | |
257 |
| - | |
258 |
| - | |
259 |
| - | |
| 267 | + | |
| 268 | + | |
260 | 269 |
| |
261 |
| - | |
262 |
| - | |
263 |
| - | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
264 | 280 |
| |
265 |
| - | |
| 281 | + | |
| 282 | + | |
266 | 283 |
| |
267 | 284 |
| |
268 | 285 |
| |
|
0 commit comments
Comments
(0)