Re: thread_test.c problems

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: PostgreSQL-general <pgsql-general(at)postgreSQL(dot)org>
Cc: wespvp(at)syntegra(dot)com, joseph speigle <joe(dot)speigle(at)jklh(dot)us>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: thread_test.c problems
Date: 2004-04-05 05:43:22
Message-ID: 200404050543.i355hMp20676@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Bruce Momjian wrote:
> > I did a cvs update, make, then rebuilt and tested thread_test. I ran it
> > about 120 times and got "GETHOSTBYNAME_THREADSAFE=yes" almost all of the
> > time. I got "GETHOSTBYNAME_THREADSAFE=no" three times. The other two were
> > always "yes".
>
> Yep, I can reproduce this on BSD/OS too, so it must be something wrong
> with my program. I see:
>
> $ for X in `jot 1000`; do thread_test |grep -10 '=no' && echo $X;
> done|less
> Make sure you have added any needed 'THREAD_CPPFLAGS' and 'THREAD_LIBS'
> defines to your template/$port file before compiling this program.
>
> Add this to your template/$port file:
>
> STRERROR_THREADSAFE=yes
> GETPWUID_THREADSAFE=no
> GETHOSTBYNAME_THREADSAFE=no
> 919
>
> I bet the problem is that I am accessing thread-specific pointers after
> the thread exits. It is possible thread 1 completes before thread2 gets
> to the getpwuid and gethostbyname tests, and then reuses the
> thread-specific pointer. Let me work on a patch and email it to you in
> a few minutes.

OK, new patch applied that causes all threads to wait until the parent
checks their thread-specific pointers. I ran 1000 tests and all passed.
Hopefully it will good for you too.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 4.3 KB

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message mike 2004-04-05 11:20:47 Re: Problem restoring Database
Previous Message wespvp 2004-04-05 04:55:57 Re: thread_test.c problems

Browse pgsql-hackers by date

  From Date Subject
Next Message Dennis Bjorklund 2004-04-05 06:40:40 Regression from 7.3 to 7.4
Previous Message wespvp 2004-04-05 04:55:57 Re: thread_test.c problems