None-reentrant function call in signal handler startup_die() - Mailing list pgsql-hackers

From samuel.coulee
Subject None-reentrant function call in signal handler startup_die()
Date
Msg-id 1540278323603-0.post@n3.nabble.com
Whole thread Raw
List pgsql-hackers
Hi,

I found that in the PG source code function BackendInitialize(), handler for
SIGTERM was set to be startup_die().  And in startup_die(), we simply call
proc_exit to exit the process. 

What's more, early in BackendInitialize() function, we called pq_init to
setup socket_close() as a process exit callback.

The problem is: in socket_close, we have some none-reentrant calls like
free(). It may cause deadlock of this backend if we are excueting
malloc/free right before we step into the signal hander startup_die(). And I
experienced that on my local server :)

Similar to the problem in this thread:
https://www.postgresql-archive.org/PG-signal-handler-and-non-reentrant-malloc-free-calls-td3403162.html.

Is there a way to avoid this deadlock in startup_die()? Thanks.. 




--
Sent from: http://www.postgresql-archive.org/PostgreSQL-hackers-f1928748.html


pgsql-hackers by date:

Previous
From: Haribabu Kommi
Date:
Subject: Re: Pluggable Storage - Andres's take
Next
From: Haribabu Kommi
Date:
Subject: Re: Pluggable Storage - Andres's take