Обсуждение: BUG #3728: pthread autoconf hangs

Поиск
Список
Период
Сортировка

BUG #3728: pthread autoconf hangs

От
"heasley"
Дата:
The following bug has been logged online:

Bug reference:      3728
Logged by:          heasley
Email address:      heas@shrubbery.net
PostgreSQL version: 8.1.10
Operating system:   sparc-sun-solaris2.9 gcc-4.1.1
Description:        pthread autoconf hangs
Details:

If the autoconf script ends-up with a CFLAGS that includes pthreads knobs,
for example -DREENTRANT, it will try to find pthread_join() without linking
in libpthread (ie: without gcc -pthread). The result is a conftest that
hangs because it has some half-baked stub for (among others)
pthread_create() that does nothing and thus it spins waiting for the
thread{1,2}_done variables to be set by a threads that do not exist.

squashing the result of the first check in config/acx_pthread.m4 allows it
find the proper results.

Sorry, I do not know the proper fix given all the platforms that need to
coexist.

Re: BUG #3728: pthread autoconf hangs

От
Zdenek Kotala
Дата:
heasley napsal(a):
> The following bug has been logged online:
>
> Bug reference:      3728
> Logged by:          heasley
> Email address:      heas@shrubbery.net
> PostgreSQL version: 8.1.10
> Operating system:   sparc-sun-solaris2.9 gcc-4.1.1
> Description:        pthread autoconf hangs
> Details:
>
> If the autoconf script ends-up with a CFLAGS that includes pthreads knobs,
> for example -DREENTRANT, it will try to find pthread_join() without linking
> in libpthread (ie: without gcc -pthread). The result is a conftest that
> hangs because it has some half-baked stub for (among others)
> pthread_create() that does nothing and thus it spins waiting for the
> thread{1,2}_done variables to be set by a threads that do not exist.
>
> squashing the result of the first check in config/acx_pthread.m4 allows it
> find the proper results.
>
> Sorry, I do not know the proper fix given all the platforms that need to
> coexist.

Please, can you provide ./configure cmd line and CFLAGS and other related
setting? Also some error output could help. Another question is gcc 4.1 is not
in Solaris 9. How did you install this version?


        Zdenek

Re: BUG #3728: pthread autoconf hangs

От
heasley
Дата:
Thu, Nov 08, 2007 at 11:04:01AM +0100, Zdenek Kotala:
> heasley napsal(a):
> >The following bug has been logged online:
> >
> >Bug reference:      3728
> >Logged by:          heasley
> >Email address:      heas@shrubbery.net
> >PostgreSQL version: 8.1.10
> >Operating system:   sparc-sun-solaris2.9 gcc-4.1.1
> >Description:        pthread autoconf hangs
> >Details:
> >
> >If the autoconf script ends-up with a CFLAGS that includes pthreads knobs,
> >for example -DREENTRANT, it will try to find pthread_join() without linking
> >in libpthread (ie: without gcc -pthread). The result is a conftest that
> >hangs because it has some half-baked stub for (among others)
> >pthread_create() that does nothing and thus it spins waiting for the
> >thread{1,2}_done variables to be set by a threads that do not exist.
> >
> >squashing the result of the first check in config/acx_pthread.m4 allows it
> >find the proper results.
> >
> >Sorry, I do not know the proper fix given all the platforms that need to
> >coexist.
>
> Please, can you provide ./configure cmd line and CFLAGS and other related
> setting? Also some error output could help. Another question is gcc 4.1 is
> not in Solaris 9. How did you install this version?

The configure is via NetBSD's pkgsrc system.

./configure --sysconfdir=/usr/pkg/etc/postgresql --datadir=/usr/pkg/share/po
stgresql --with-docdir=/usr/pkg/share/doc/postgresql --with-template=solaris --w
ithout-readline --without-zlib --enable-nls --without-java --without-perl --with
out-python --without-tcl --with-openssl --with-readline --with-zlib --enable-thr
ead-safety --with-libiconv-prefix=/usr/pkg --with-libintl-prefix=/usr/pkg --pref
ix=/usr/pkg --host=sparc-sun-solaris2 --mandir=/usr/pkg/man

from config.log:
CFLAGS=-g -static-libgcc -static-libgcc -D_LARGEFILE64_SOURCE -mcpu=v9 -mtune=ultrasparc -m64 -D__sparc_v9__ -pipe
-I/usr/pkg/include-I/usr/include -Wall -Wmissing-prototypes -Wpointer-arith -Winline -Wdeclaration-after-statement
-Wendif-labels-fno-strict-aliasing 

www.shrubbery.net/~heas/pg_config.log.txt
www.shrubbery.net/~heas/conftest.c.txt

I built gcc 4.1, after having some difficulty with other versions.  It is a
fairly straight forward build, expect that it has a hack to avoid a libiconv
bug and is within a wrapper script that forces 64-bit options.  I did not have
this problem with pre-8.1.5 postgres as I recall; 8.1.4 built fine and I do
not believe there have been any pkgsrc changes that would affect this.

I did try adding an if () around the pthread_create()s, but it would seem that
they return 0.  And, indeed conftest did not have libpthread linked.

yew [22] ldd conftest
        libintl.so.3 =>  /usr/pkg/lib/libintl.so.3
        libssl.so.0.9.7 =>       /usr/pkg/lib/libssl.so.0.9.7
        libcrypto.so.0.9.7 =>    /usr/pkg/lib/libcrypto.so.0.9.7
        libz.so.1 =>     /usr/pkg/lib/libz.so.1
        libreadline.so.5 =>      /usr/pkg/lib/libreadline.so.5
        librt.so.1 =>    /usr/lib/64/librt.so.1
        libresolv.so.2 =>        /usr/lib/64/libresolv.so.2
        libgen.so.1 =>   /usr/lib/64/libgen.so.1
        libsocket.so.1 =>        /usr/lib/64/libsocket.so.1
        libnsl.so.1 =>   /usr/lib/64/libnsl.so.1
        libdl.so.1 =>    /usr/lib/64/libdl.so.1
        libm.so.1 =>     /usr/lib/64/libm.so.1
        libc.so.1 =>     /usr/lib/64/libc.so.1
        libiconv.so.2 =>         /usr/pkg/lib/libiconv.so.2
        libcurses.so.1 =>        /usr/lib/64/libcurses.so.1
        libaio.so.1 =>   /usr/lib/64/libaio.so.1
        libmd5.so.1 =>   /usr/lib/64/libmd5.so.1
        libmp.so.2 =>    /usr/lib/64/libmp.so.2
        /usr/platform/SUNW,Sun-Fire-280R/lib/sparcv9/libc_psr.so.1
        /usr/platform/SUNW,Sun-Fire-280R/lib/sparcv9/libmd5_psr.so.1

indeed there are weak symbols in libc:
[2776]  |        676344|          36|FUNC |WEAK |0    |9      |_pthread_create
[4109]  |        676580|          40|FUNC |WEAK |0    |9      |_pthread_join
[3999]  |        674772|          36|FUNC |WEAK |0    |9      |_pthread_mutex_lock

Re: BUG #3728: pthread autoconf hangs

От
Zdenek Kotala
Дата:
heasley wrote:
> Thu, Nov 08, 2007 at 11:04:01AM +0100, Zdenek Kotala:
>> heasley napsal(a):

>
> The configure is via NetBSD's pkgsrc system.
>
> ./configure --sysconfdir=/usr/pkg/etc/postgresql --datadir=/usr/pkg/share/po
> stgresql --with-docdir=/usr/pkg/share/doc/postgresql --with-template=solaris --w
> ithout-readline --without-zlib --enable-nls --without-java --without-perl --with
> out-python --without-tcl --with-openssl --with-readline --with-zlib --enable-thr
> ead-safety --with-libiconv-prefix=/usr/pkg --with-libintl-prefix=/usr/pkg --pref
> ix=/usr/pkg --host=sparc-sun-solaris2 --mandir=/usr/pkg/man

It is really strange configure. See --with-readline/--without-readline.
Unfrotunately I currently does not have system with S9 similar to yours
configuration :(. I tested Sun Studio compiler with following configure
switch ./configure --without-readline --enable-thread-safety and it
works fine. Can you try Sun studio?

http://developers.sun.com/sunstudio/downloads/thankyou.jsp?submit=%A0FREE+Download%A0%BB%A0

> from config.log:
> CFLAGS=-g -static-libgcc -static-libgcc -D_LARGEFILE64_SOURCE -mcpu=v9 -mtune=ultrasparc -m64 -D__sparc_v9__ -pipe
-I/usr/pkg/include-I/usr/include -Wall -Wmissing-prototypes -Wpointer-arith -Winline -Wdeclaration-after-statement
-Wendif-labels-fno-strict-aliasing 

Can you try build it as 32bit application? If there is not problem with
64bit libraries.

> www.shrubbery.net/~heas/pg_config.log.txt
> www.shrubbery.net/~heas/conftest.c.txt
>
> I built gcc 4.1, after having some difficulty with other versions.  It is a
> fairly straight forward build, expect that it has a hack to avoid a libiconv
> bug and is within a wrapper script that forces 64-bit options.  I did not have
> this problem with pre-8.1.5 postgres as I recall; 8.1.4 built fine and I do
> not believe there have been any pkgsrc changes that would affect this.

I don't see any difference in ./configure related to pthread. Do you use
same process for building? Do you have same version of all libraries,
GCC or did you update some version? Can you compile 8.1.4 with same
configuration?

It seems to me that it could be something wrong with your GCC compilation.

        Zdenek

Re: BUG #3728: pthread autoconf hangs

От
heasley
Дата:
Fri, Nov 09, 2007 at 12:17:42PM +0100, Zdenek Kotala:
> heasley wrote:
> >Thu, Nov 08, 2007 at 11:04:01AM +0100, Zdenek Kotala:
> >>heasley napsal(a):
>
> >
> >The configure is via NetBSD's pkgsrc system.
> >
> >./configure --sysconfdir=/usr/pkg/etc/postgresql
> >--datadir=/usr/pkg/share/po
> >stgresql --with-docdir=/usr/pkg/share/doc/postgresql
> >--with-template=solaris --w
> >ithout-readline --without-zlib --enable-nls --without-java --without-perl
> >--with
> >out-python --without-tcl --with-openssl --with-readline --with-zlib
> >--enable-thr
> >ead-safety --with-libiconv-prefix=/usr/pkg --with-libintl-prefix=/usr/pkg
> >--pref
> >ix=/usr/pkg --host=sparc-sun-solaris2 --mandir=/usr/pkg/man
>
> It is really strange configure. See --with-readline/--without-readline.
> Unfrotunately I currently does not have system with S9 similar to yours
> configuration :(. I tested Sun Studio compiler with following configure
> switch ./configure --without-readline --enable-thread-safety and it
> works fine. Can you try Sun studio?
>
> http://developers.sun.com/sunstudio/downloads/thankyou.jsp?submit=%A0FREE+Download%A0%BB%A0
>
> >from config.log:
> >CFLAGS=-g -static-libgcc -static-libgcc -D_LARGEFILE64_SOURCE -mcpu=v9
> >-mtune=ultrasparc -m64 -D__sparc_v9__ -pipe -I/usr/pkg/include
> >-I/usr/include -Wall -Wmissing-prototypes -Wpointer-arith -Winline
> >-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
>
> Can you try build it as 32bit application? If there is not problem with
> 64bit libraries.

sort of; I do not have 32bit readline, openssl, etc. and I do not have
sunstudio ATM [sorry, I have very little free time].  I can try sunCC
later.

just using gcc, outside of the pkgsrc system, it will still be 64-bit
(since I have a wrapper around gcc that forces the 64bit options), it
builds.  But, this success is an accident.  It claims to be "checking
without flags", but in fact it has -pthread [from where?].

configure:16405: checking whether pthreads work without any flags
configure:16498: gcc -o conftest -g -static-libgcc -Wall -Wmissing-prototypes -W
pointer-arith -Winline -Wdeclaration-after-statement -Wendif-labels -fno-strict-
aliasing -Wall -Wmissing-prototypes -Wpointer-arith -Winline -Wdeclaration-after
-statement -Wendif-labels -fno-strict-aliasing  -pthread -pthreads       conftes
t.c   -lpthread      -lz -lrt -lresolv -lgen -lsocket -lnsl -ldl -lm  >&5
configure:16504: $? = 0
configure:16508: test -z
                         || test ! -s conftest.err
configure:16511: $? = 0
configure:16514: test -s conftest
configure:16517: $? = 0
configure:16555: result: yes

www.shrubbery.net/~heas/pg_config.log2.txt

> >www.shrubbery.net/~heas/pg_config.log.txt
> >www.shrubbery.net/~heas/conftest.c.txt
> >
> >I built gcc 4.1, after having some difficulty with other versions.  It is a
> >fairly straight forward build, expect that it has a hack to avoid a
> >libiconv
> >bug and is within a wrapper script that forces 64-bit options.  I did not
> >have
> >this problem with pre-8.1.5 postgres as I recall; 8.1.4 built fine and I do
> >not believe there have been any pkgsrc changes that would affect this.
>
> I don't see any difference in ./configure related to pthread. Do you use
> same process for building? Do you have same version of all libraries,
> GCC or did you update some version? Can you compile 8.1.4 with same
> configuration?

yes, it does build, but for the reason as below.

> It seems to me that it could be something wrong with your GCC compilation.

I wouldn't put anything past gcc, but I do not think it is at fault here.
My understanding, at least for NetBSD, FreeBSD and Solaris, is that they
all require -pthread; which essentially adds -lpthread.  So, unless you
have some dependency that picks-up libpthread, you get these bogus (I
agree) stubs from libc which I'd suspect are the cause of the spinning.