- Notifications
You must be signed in to change notification settings - Fork5
Commit910bac5
committed
Fix possible crashes due to using elog/ereport too early in startup.
Per reports from Andres Freund and Luke Campbell, a server failure duringset_pglocale_pgservice results in a segfault rather than a useful errormessage, because the infrastructure needed to use ereport hasn't beeninitialized; specifically, MemoryContextInit hasn't been called.One known cause of this is starting the server in a directory itdoesn't have permission to read.We could try to prevent set_pglocale_pgservice from using anything thatdepends on palloc or elog, but that would be messy, and the odds of futurebreakage seem high. Moreover there are other things being called in main.cthat look likely to use palloc or elog too --- perhaps those thingsshouldn't be there, but they are there today. The best solution seems tobe to move the call of MemoryContextInit to very early in the backend'sreal main() function. I've verified that an elog or ereport occurringimmediately after that is now capable of sending something useful tostderr.I also added code to elog.c to print something intelligible rather thanjust crashing if MemoryContextInit hasn't created the ErrorContext.This could happen if MemoryContextInit itself fails (due to mallocfailure), and provides some future-proofing against someone trying tosneak in new code even earlier in server startup.Back-patch to all supported branches. Since we've only heard reports ofthis type of failure recently, it may be that some recent change has madeit more likely to see a crash of this kind; but it sure looks like it'sbroken all the way back.1 parentd84c584 commit910bac5
File tree
6 files changed
+36
-23
lines changed- src/backend
- bootstrap
- main
- postmaster
- tcop
- utils
- error
- mmgr
6 files changed
+36
-23
lines changedLines changed: 0 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
202 | 202 |
| |
203 | 203 |
| |
204 | 204 |
| |
205 |
| - | |
206 |
| - | |
207 |
| - | |
208 |
| - | |
209 |
| - | |
210 |
| - | |
211 |
| - | |
212 |
| - | |
213 | 205 |
| |
214 | 206 |
| |
215 | 207 |
| |
|
Lines changed: 10 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
39 | 39 |
| |
40 | 40 |
| |
41 | 41 |
| |
| 42 | + | |
42 | 43 |
| |
43 | 44 |
| |
44 | 45 |
| |
| |||
85 | 86 |
| |
86 | 87 |
| |
87 | 88 |
| |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
88 | 98 |
| |
89 | 99 |
| |
90 | 100 |
| |
|
Lines changed: 0 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
560 | 560 |
| |
561 | 561 |
| |
562 | 562 |
| |
563 |
| - | |
564 |
| - | |
565 |
| - | |
566 |
| - | |
567 |
| - | |
568 | 563 |
| |
569 | 564 |
| |
570 | 565 |
| |
| |||
4468 | 4463 |
| |
4469 | 4464 |
| |
4470 | 4465 |
| |
4471 |
| - | |
4472 | 4466 |
| |
4473 | 4467 |
| |
4474 | 4468 |
| |
|
Lines changed: 0 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3548 | 3548 |
| |
3549 | 3549 |
| |
3550 | 3550 |
| |
3551 |
| - | |
3552 |
| - | |
3553 |
| - | |
3554 |
| - | |
3555 |
| - | |
3556 |
| - | |
3557 |
| - | |
3558 |
| - | |
3559 | 3551 |
| |
3560 | 3552 |
| |
3561 | 3553 |
| |
|
Lines changed: 21 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
310 | 310 |
| |
311 | 311 |
| |
312 | 312 |
| |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
313 | 325 |
| |
314 | 326 |
| |
315 | 327 |
| |
| |||
1238 | 1250 |
| |
1239 | 1251 |
| |
1240 | 1252 |
| |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
1241 | 1262 |
| |
1242 | 1263 |
| |
1243 | 1264 |
| |
|
Lines changed: 5 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
72 | 72 |
| |
73 | 73 |
| |
74 | 74 |
| |
75 |
| - | |
| 75 | + | |
| 76 | + | |
76 | 77 |
| |
77 | 78 |
| |
78 | 79 |
| |
| |||
106 | 107 |
| |
107 | 108 |
| |
108 | 109 |
| |
| 110 | + | |
| 111 | + | |
| 112 | + | |
109 | 113 |
| |
110 | 114 |
| |
111 | 115 |
| |
|
0 commit comments
Comments
(0)