In Pgpool-II 4.1 or before log_line_prefix unconditionally tried to
fetch the application name from backend info (slots array).
Unfortunately in certain corner cases this was not possible. When
connection_cache is off, pgpool resets connection slots
(session->backend->slots[]) at the time when clients sends termination
request to pgpool. If log_min_messages is DEBUG5, pgpool wants to emit
this log message:
DEBUG: RESET ALL CONFIG VARIABLE
which caused a segfault because pgpool tried to refer NULL pointer.
Fix is, if session->backend->slots[] is NULL, do not try to fetch
application name from the variable.
Per bug 615.
* pool_virtual_master_db_node_id() which eventually calls
* ereport() if operated in DEBUG mode.
*/
- StartupPacket *sp = session? (session->backend->slots[REAL_MASTER_NODE_ID])->sp : NULL ;
+ StartupPacket *sp = (session && session->backend && (session->backend->slots[REAL_MASTER_NODE_ID]))? \
+ (session->backend->slots[REAL_MASTER_NODE_ID])->sp: NULL;
const char *appname = sp? sp->application_name : "[No Connection]";
if (appname == NULL || *appname == '\0')
appname = "[unknown]";