diff options
Diffstat (limited to 'src/backend/utils/error')
-rw-r--r-- | src/backend/utils/error/elog.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 3de162b9d53..8705586d565 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -311,6 +311,18 @@ errstart(int elevel, const char *filename, int lineno, return false; /* + * We need to do some actual work. Make sure that memory context + * initialization has finished, else we can't do anything useful. + */ + if (ErrorContext == NULL) + { + /* Ooops, hard crash time; very little we can do safely here */ + write_stderr("error occurred at %s:%d before error message processing is available\n", + filename ? filename : "(unknown file)", lineno); + exit(2); + } + + /* * Okay, crank up a stack entry to store the info in. */ @@ -1238,6 +1250,15 @@ elog_start(const char *filename, int lineno, const char *funcname) { ErrorData *edata; + /* Make sure that memory context initialization has finished */ + if (ErrorContext == NULL) + { + /* Ooops, hard crash time; very little we can do safely here */ + write_stderr("error occurred at %s:%d before error message processing is available\n", + filename ? filename : "(unknown file)", lineno); + exit(2); + } + if (++errordata_stack_depth >= ERRORDATA_STACK_SIZE) { /* |