Re: PG signal handler and non-reentrant malloc/free calls

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: PG signal handler and non-reentrant malloc/free calls
Дата
Msg-id 4D6B949C.5050903@enterprisedb.com
обсуждение исходный текст
Ответ на PG signal handler and non-reentrant malloc/free calls  (Nikhil Sontakke <nikhil.sontakke@enterprisedb.com>)
Ответы Re: PG signal handler and non-reentrant malloc/free calls  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: PG signal handler and non-reentrant malloc/free calls  (Nikhil Sontakke <nikhil.sontakke@enterprisedb.com>)
Список pgsql-hackers
On 28.02.2011 14:04, Nikhil Sontakke wrote:
> I believe we have a case where not holding off interrupts while doing a
> malloc() can cause a deadlock due to system or libc level locking. In this
> case, a pg_ctl stop in fast mode was resorted to and that caused a backend
> to handle the interrupt when it was inside the malloc call. Now as part of
> the abort processing, in the subtransaction cleanup code path, this same
> backend tried to clear memory contexts, leading to an eventual free() call.
> The free() call tried to take the same lock which was already held by
> malloc() earlier resulting into a deadlock!

Our signal handlers shouldn't try to do anything that complicated. 
die(), which handles SIGTERM caused by fast shutdown in backends, 
doesn't do abort processing itself. It just sets a global variable.

Unless ImmediateInterruptOK is set, but it's only set around a few 
blocking system calls where it is safe to do so. (Checks...) Actually, 
md5_crypt_verify() looks suspicious, it does "ImmediateInterruptOK = 
true", and then calls palloc() and pfree().

> Will try to get the call stack if needed.

Yes, please.

--   Heikki Linnakangas  EnterpriseDB   http://www.enterprisedb.com


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Nikhil Sontakke
Дата:
Сообщение: PG signal handler and non-reentrant malloc/free calls
Следующее
От: Fujii Masao
Дата:
Сообщение: Re: Replication server timeout patch