Re: Server crash with older tzload library

Поиск
Список
Период
Сортировка
От Jeevan Chalke
Тема Re: Server crash with older tzload library
Дата
Msg-id be46a4f31003120104q5647d040i121f790f1f098b1a@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Server crash with older tzload library  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Server crash with older tzload library
Список pgsql-hackers
Hi Tom,

On Thu, Mar 11, 2010 at 8:29 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Jeevan Chalke <jeevan.chalke@enterprisedb.com> writes:
> While setting timezone using SET command (say GMT+3:30), postgres sometimes
> crashes randomly.

I can't reproduce that:

regression=# SET TimeZone = 'GMT+3:30';
SET
regression=# SELECT '1969-12-31 20:30:00'::timestamptz;
       timestamptz
---------------------------
 1969-12-31 20:30:00-03:30
(1 row)


Even we were fail to re-produce it always. It is crashing randomly. After debugging, we found following values in tzstate variable when it crashed. So I manually modified it at the beginning of pg_tzset() function.

/* Initialize tzstate with some arbitrary values */
tzstate.goback = 277946440;
tzstate.goahead = 0;
tzstate.ats[0] = 8892;

Also not that, tzstate variable remains uninitialized properly when tzload() call returns -1. To mimic this, I have just renamed posixrules timezone file to something else. So that tzload returns -1. And as tzload can return -1 in any failure case and as we don't have that check at callee side tzstate variable remains uninitialized which leading to a server crash. As above garbage values too leads to a crash.

In summary, following are the steps to re-produce:
 - Add above three lines at the beginning of the pg_tzset() function
 - make install
 - mv install/share/postgresql/timezone/posixrules install/share/postgresql/timezoneposixrules_a  (or remove it)
 - start the server
 - run these two statements on psql prompt
   + SET TimeZone = 'GMT+3:30';
   + SELECT '1969-12-31 20:30:00'::timestamptz;

BTW, after your commit, tzload() function now sets goback and goahead variable to FALSE which fixes the server crash. MemSet in 2010c is just doing it explicitly before calling tzload though.

Thanks for committing the part of the patch which stopped crashing the server with above mentioned steps.

Thanks


                       regards, tom lane



--
Jeevan B Chalke
Software Engineer, R&D
EnterpriseDB Corporation
The Enterprise Postgres Company

Phone: +91 20 30589500

Website: www.enterprisedb.com
EnterpriseDB Blog: http://blogs.enterprisedb.com/
Follow us on Twitter: http://www.twitter.com/enterprisedb

This e-mail message (and any attachment) is intended for the use of the individual or entity to whom it is addressed. This message contains information from EnterpriseDB Corporation that may be privileged, confidential, or exempt from disclosure under applicable law. If you are not the intended recipient or authorized to receive this for the intended recipient, any use, dissemination, distribution, retention, archiving, or copying of this communication is strictly prohibited. If you have received this e-mail in error, please notify the sender immediately by reply e-mail and delete this message.

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

Предыдущее
От: Simon Riggs
Дата:
Сообщение: Re: Assertion failure twophase.c (2) (testing HS/SR)
Следующее
От: Dag-Erling Smørgrav
Дата:
Сообщение: Re: [patch] build issues on Win32