解决初始化阶段分配内存失败导致空指针core的问题

(cherry picked commit from <gitee.com//opengauss/openGauss-server/commit/ad090a92ad9abe3fd50dbd05633ed0a8c60b6d54>
This commit is contained in:
laishenghao
2024-09-24 14:57:06 +08:00
committed by laishenghao
parent b78d3cea15
commit d97d0b1a5d

View File

@ -321,14 +321,20 @@ bool errstart(int elevel, const char* filename, int lineno, const char* funcname
elevel = ERROR;
}
}
if (u_sess == NULL && (g_instance.role == VUNKNOWN || t_thrd.role == MASTER_THREAD)) {
// there out of memory in startup, we exit directly.
/* 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"
" u_sess is NULL! gaussdb is exit now.\n",
filename ? filename : "(unknown file)",
lineno);
_exit(-1);
if (unlikely(u_sess == NULL)) {
if (g_instance.role == VUNKNOWN || t_thrd.role == MASTER_THREAD) {
// there out of memory in startup, we exit directly.
/* 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"
" u_sess is NULL! gaussdb is exit now.\n",
filename ? filename : "(unknown file)", lineno);
_exit(STATUS_ERROR);
} else {
write_stderr("error occurred at %s:%d before session context available, u_sess is NULL.\n",
filename ? filename : "(unknown file)", lineno);
ThreadExitCXX(STATUS_ERROR);
}
}
/*
* Now decide whether we need to process this report at all; if it's