None-reentrant function call in signal handler startup_die()

From: "samuel(dot)coulee" <313914592(at)qq(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: None-reentrant function call in signal handler startup_die()
Date: 2018-10-23 07:05:23
Message-ID: 1540278323603-0.post@n3.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-hackers by date

  From Date Subject
Next Message Haribabu Kommi 2018-10-23 07:11:51 Re: Pluggable Storage - Andres's take
Previous Message Haribabu Kommi 2018-10-23 06:49:23 Re: Pluggable Storage - Andres's take