Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 158509 - dev-db/libpq-8.0.9 fails configure with segmentation fault in thread_test.c
Summary: dev-db/libpq-8.0.9 fails configure with segmentation fault in thread_test.c
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Library (show other bugs)
Hardware: AMD64 Linux
: High normal
Assignee: PgSQL Bugs
URL:
Whiteboard:
Keywords:
: 177310 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-12-18 16:54 UTC by Andreas Plesch
Modified: 2011-01-25 14:32 UTC (History)
8 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Error message during configure (libpq_config.txt,6.95 KB, text/plain)
2006-12-19 12:03 UTC, Andreas Plesch
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Plesch 2006-12-18 16:54:03 UTC
Following an emerge --sync, emerge libpq configures libpq-8.0.9 which then fails with this message:

...
checking thread safety of required library functions... no
configure: error:
*** Thread test program failed.  Your platform is not thread-safe.
*** Check the file 'config.log'for the exact reason.
***
*** You can use the configure option --enable-thread-safety-force
*** to force threads to be enabled.  However, you must then run
*** the program in src/tools/thread and add locking function calls
*** to your applications to guarantee thread safety.

Said config_log has:

...
configure:18962: checking thread safety of required library functions
configure:18987: x86_64-pc-linux-gnu-gcc -o conftest -march=opteron -O2 -pipe -Wall
 -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels
-fno-strict-aliasing  -pthread  -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANT
ICS -DIN_CONFIGURE -D_GNU_SOURCE    conftest.c -lpam -lssl -lcrypto -lz -lreadline
-lcrypt -lresolv -lnsl -ldl -lm -lbsd   -lpthread    >&5
configure:18990: $? = 0
configure:18992: ./conftest
./configure: line 18993:   783 Segmentation fault      ./conftest$ac_exeext
configure:18995: $? = 139
configure: program exited with status 139
configure: failed program was:
#line 18981 "configure"
#include "confdefs.h"
#include "./src/tools/thread/thread_test.c"
configure:19004: result: no
configure:19014: error:
*** Thread test program failed.  Your platform is not thread-safe.
*** Check the file 'config.log'for the exact reason.
***
*** You can use the configure option --enable-thread-safety-force
*** to force threads to be enabled.  However, you must then run
*** the program in src/tools/thread and add locking function calls
*** to your applications to guarantee thread safety.

USE="-threads" emerge libpq succeeds.

Finally, here emerge --info

Portage 2.1.1-r2 (default-linux/amd64/2006.1/desktop, gcc-3.4.6, glibc-2.4-r4, 2.6.16-gentoo-r12 x86_64)
=================================================================
System uname: 2.6.16-gentoo-r12 x86_64 AMD Opteron(tm) Processor 252
Gentoo Base System version 1.12.6
Last Sync: Mon, 18 Dec 2006 18:30:01 +0000
app-admin/eselect-compiler: [Not Present]
dev-java/java-config: 1.3.7, 2.0.31
dev-lang/python:     2.3.5-r2, 2.4.3-r4
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     [Not Present]
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.60
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2
sys-devel/binutils:  2.16.1-r3
sys-devel/gcc-config: 1.3.14
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.11-r2
ACCEPT_KEYWORDS="amd64"
AUTOCLEAN="yes"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=opteron -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.4/env /usr/kde/3.4/share/config /usr/kde/3.4/shutdown /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/X11/xkb /usr/share/config"
CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/gconf /etc/java-config/vms/ /etc/revdep-rebuild /etc/terminfo /etc/texmf/web2c"
CXXFLAGS="-march=opteron -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig distlocks metadata-transfer sandbox sfperms strict"
GENTOO_MIRRORS="http://128.213.5.34/gentoo http://www.ibiblio.org/pub/Linux/distributions/gentoo"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude='/distfiles' --exclude='/local' --exclude='/packages'"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="amd64 X alsa arts berkdb bitmap-fonts cairo cdr cli cracklib crypt cups dbus dlloader dri dv dvd dvdr dvdread eds elibc_glibc emacs emboss encode esd fam firefox flash font-server fortran gd gdbm gif gpm gstreamer gtk gtk2 hal iconv ieee1394 imap input_devices_keyboard input_devices_mouse ipv6 isdnlog jpeg kde kernel_linux lcms ldap libg++ live mad mikmod mjpeg mp3 mpeg ncurses nls nptl nptlonly odbc ogg opengl oss pam pcre perl plotutils png postgres ppds pppd python qt qt3 qt4 quicktime readline reflection samba sdl session smp spell spl ssl svg tcpd threads tiff truetype truetype-fonts type1-fonts udev unicode usb userland_GNU video_cards_fbdev video_cards_nv video_cards_nvidia video_cards_vesa vorbis wmf xinerama xml xorg xv zlib"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, LINGUAS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Tiziano Müller (RETIRED) gentoo-dev 2006-12-18 21:42:37 UTC
Hmm, did you already retry the emerge? If not, could you do so? Thanks.
Comment 2 Andreas Plesch 2006-12-19 12:00:53 UTC
(In reply to comment #1)
> Hmm, did you already retry the emerge? If not, could you do so? Thanks.

I am not quite sure what you are suggesting. Anyway, here is what I did after your response. I just did a emerge --sync but there is no new (stable) ebuild for libpq. Then I did a emerge libpq with threading enabled:

# emerge -pv libpq

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R   ] dev-db/libpq-8.0.9  USE="nls pam readline ssl threads* zlib -kerberos -pg-intdatetime" 0 kB

# emerge -v libpq &> libpq_thread.log

Configure then does its checking but still fails at the same threading test, now with a more verbose error message including a backtrace:

[attached below]

Since glibc seems to be involved, here my USE variable for it:

# emerge -pv glibc

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R   ] sys-libs/glibc-2.4-r4  USE="nls nptl nptlonly -build -glibc-compat20 -glibc-omitfp -hardened (-multilib) -profile (-selinux)" 129 kB

config.log for libpq still has the same message:

# more /var/tmp/portage/libpq-8.0.9/work/postgresql-8.0.9/config.log
...
configure:18987: x86_64-pc-linux-gnu-gcc -o conftest -march=opteron -O2 -pipe -Wall
 -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels
-fno-strict-aliasing  -pthread  -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANT
ICS -DIN_CONFIGURE -D_GNU_SOURCE    conftest.c -lpam -lssl -lcrypto -lz -lreadline
-lcrypt -lresolv -lnsl -ldl -lm -lbsd   -lpthread    >&5
configure:18990: $? = 0
configure:18992: ./conftest
./configure: line 18993: 31412 Aborted                 ./conftest$ac_exeext
configure:18995: $? = 134
configure: program exited with status 134
configure: failed program was:
#line 18981 "configure"
#include "confdefs.h"
#include "./src/tools/thread/thread_test.c"
configure:19004: result: no
configure:19014: error:
*** Thread test program failed.  Your platform is not thread-safe.
*** Check the file 'config.log'for the exact reason.
***
*** You can use the configure option --enable-thread-safety-force
*** to force threads to be enabled.  However, you must then run
*** the program in src/tools/thread and add locking function calls
*** to your applications to guarantee thread safety.

Finally I disabled threading again (USE=-threads) and reemerge to have a somewhat functioning postgresql installation.
Comment 3 Andreas Plesch 2006-12-19 12:03:12 UTC
Created attachment 104385 [details]
Error message during configure

conftest.c segmentation fault during configure
Comment 4 Steve L 2007-01-01 13:38:04 UTC
I'm getting exactly the same error (line 18993: Segmentation fault) on Intel Core2 Duo (EM64T) with similar glibc setup (nptl, nptl-only) so I guess it's a 64-bit issue.
Comment 5 Steve L 2007-01-01 14:01:10 UTC
There's also this thread http://forums.gentoo.org/viewtopic-t-463344.html which was started in May, and had people posting til October, apparently with no result, so it's clearly effecting others.
Comment 6 Frank-Ralph Reiser 2007-02-12 10:42:58 UTC
This error occurred here, too. (intel, 32bit)
The second time it emerged successfully - the only two packages that were upgraded in between are
 sys-fs/udev-104-r10 [104-r9] 
 app-text/poppler-0.5.4-r1 [0.5.4]


CFLAGS="-march=prescott -O2 -pipe -mno-tls-direct-seg-refs"
CHOST="i686-pc-linux-gnu"




checking for collateindex.pl... /usr/bin/collateindex.pl
checking for sgmlspl... no
checking thread safety of required library functions... *** glibc detected *** ./conftest: double free or corruption (!prev): 0x08052230 ***
======= Backtrace: =========
/lib/libc.so.6[0xb7c10147]
/lib/libc.so.6(__libc_free+0x7a)[0xb7c11704]
/usr/lib/libsandbox.so[0xb7f39fd1]
/usr/lib/libsandbox.so[0xb7f3a09c]
/usr/lib/libsandbox.so[0xb7f39f28]
/usr/lib/libsandbox.so[0xb7f3d4c0]
/lib/ld-linux.so.2[0xb7f50f58]
/lib/libc.so.6(exit+0xdb)[0xb7bd8283]
/lib/libc.so.6(__libc_start_main+0xe4)[0xb7bc282c]
./conftest[0x8048871]
======= Memory map: ========
08048000-08049000 r-xp 00000000 08:03 16902521   /var/tmp/portage/dev-db/libpq-8.1.8/work/postgresql-8.1.8/conftest
08049000-0804a000 rw-p 00001000 08:03 16902521   /var/tmp/portage/dev-db/libpq-8.1.8/work/postgresql-8.1.8/conftest
0804a000-080eb000 rw-p 0804a000 00:00 0          [heap]
b6a00000-b6a21000 rw-p b6a00000 00:00 0 
b6a21000-b6b00000 ---p b6a21000 00:00 0 
b6b69000-b6b6a000 ---p b6b69000 00:00 0 
b6b6a000-b736a000 rw-p b6b6a000 00:00 0 
b736a000-b736b000 ---p b736a000 00:00 0 
b736b000-b7b6d000 rw-p b736b000 00:00 0 
b7b6d000-b7ba4000 r-xp 00000000 08:03 35055705   /lib/libncurses.so.5.5
b7ba4000-b7bac000 rw-p 00037000 08:03 35055705   /lib/libncurses.so.5.5
b7bac000-b7bad000 rw-p b7bac000 00:00 0 
b7bad000-b7ccc000 r-xp 00000000 08:03 63166283   /lib/libc-2.5.so
b7ccc000-b7ccd000 r--p 0011f000 08:03 63166283   /lib/libc-2.5.so
b7ccd000-b7ccf000 rw-p 00120000 08:03 63166283   /lib/libc-2.5.so
b7ccf000-b7cd2000 rw-p b7ccf000 00:00 0 
b7cd2000-b7ce4000 r-xp 00000000 08:03 63164547   /lib/libpthread-2.5.so
b7ce4000-b7ce5000 r--p 00011000 08:03 63164547   /lib/libpthread-2.5.so
b7ce5000-b7ce6000 rw-p 00012000 08:03 63164547   /lib/libpthread-2.5.so
b7ce6000-b7ce8000 rw-p b7ce6000 00:00 0 
b7ce8000-b7d0a000 r-xp 00000000 08:03 63128179   /lib/libm-2.5.so
b7d0a000-b7d0c000 rw-p 00021000 08:03 63128179   /lib/libm-2.5.so
b7d0c000-b7d0d000 rw-p b7d0c000 00:00 0 
b7d0d000-b7d0f000 r-xp 00000000 08:03 63128193   /lib/libdl-2.5.so
b7d0f000-b7d11000 rw-p 00001000 08:03 63128193   /lib/libdl-2.5.so
b7d11000-b7d22000 r-xp 00000000 08:03 63164559   /lib/libnsl-2.5.so
b7d22000-b7d24000 rw-p 00010000 08:03 63164559   /lib/libnsl-2.5.so
b7d24000-b7d26000 rw-p b7d24000 00:00 0 
b7d26000-b7d34000 r-xp 00000000 08:03 63164548   /lib/libresolv-2.5.so
b7d34000-b7d36000 rw-p 0000d000 08:03 63164548   /lib/libresolv-2.5.so
b7d36000-b7d38000 rw-p b7d36000 00:00 0 
b7d38000-b7d3d000 r-xp 00000000 08:03 63128621   /lib/libcrypt-2.5.so
b7d3d000-b7d3f000 rw-p 00004000 08:03 63128621   /lib/libcrypt-2.5.so
b7d3f000-b7d66000 rw-p b7d3f000 00:00 0 
b7d66000-b7d8f000 r-xp 00000000 08:03 25308477   /lib/libreadline.so.5.1
b7d8f000-b7d93000 rw-p 00028000 08:03 25308477   /lib/libreadline.so.5.1
b7d93000-b7d94000 rw-p b7d93000 00:00 0 
b7d94000-b7da5000 r-xp 00000000 08:03 30334948   /lib/libz.so.1.2.3
b7da5000-b7da6000 rw-p 00010000 08:03 30334948   /lib/libz.so.1.2.3
b7da6000-b7da7000 rw-p b7da6000 00:00 0 
b7da7000-b7ebc000 r-xp 00000000 08:03 293555     /usr/lib/libcrypto.so.0.9.8
b7ebc000-b7ed0000 rw-p 00114000 08:03 293555     /usr/lib/libcrypto.so.0.9.8
b7ed0000-b7ed4000 rw-p b7ed0000 00:00 0 
b7ed4000-b7f0d000 r-xp 00000000 08:03 293587     /usr/lib/libssl.so.0.9.8
b7f0d000-b7f11000 rw-p 00038000 08:03 293587     /usr/lib/libssl.so.0.9.8
b7f11000-b7f18000 r-xp 00000000 08:03 9503609    /lib/libpam.so.0.78
b7f18000-b7f19000 rw-p 00006000 08:03 9503609    /lib/libpam.so.0.78
b7f2e000-b7f37000 r-xp 00000000 08:03 21055367   /usr/lib/gcc/i686-pc-linux-gnu/4.1.1/libgcc_s.so.1
b7f37000-b7f38000 rw-p 00008000 08:03 21055367   /usr/lib/gcc/i686-pc-linux-gnu/4.1.1/libgcc_s.so.1
b7f38000-b7f39000 rw-p b7f38000 00:00 0 
b7f39000-b7f3e000 r-xp 00000000 08:03 50612746   /usr/lib/libsandbox.so.0.0.0
b7f3e000-b7f3f000 rw-p 00005000 08:03 50612746   /usr/lib/libsandbox.so.0.0.0
b7f3f000-b7f42000 rw-p b7f3f000 00:00 0 
b7f42000-b7f43000 r-xp b7f42000 00:00 0          [vdso]
b7f43000-b7f5d000 r-xp 00000000 08:03 63166307   /lib/ld-2.5.so
b7f5d000-b7f5e000 r--p 00019000 08:03 63166307   /lib/ld-2.5.so
b7f5e000-b7f5f000 rw-p 0001a000 08:03 63166307   /lib/ld-2.5.so
bf926000-bf93e000 rw-p bf926000 00:00 0          [stack]
no
configure: error:
*** Thread test program failed.  Your platform is not thread-safe.
*** Check the file 'config.log'for the exact reason.
***
*** You can use the configure option --enable-thread-safety-force
*** to force threads to be enabled.  However, you must then run
*** the program in src/tools/thread and add locking function calls
*** to your applications to guarantee thread safety.


!!! ERROR: dev-db/libpq-8.1.8 failed.
Call stack:
  ebuild.sh, line 1614:   Called dyn_compile
  ebuild.sh, line 971:   Called qa_call 'src_compile'
  environment, line 3289:   Called src_compile
  libpq-8.1.8.ebuild, line 71:   Called die

!!! configure failed
!!! If you need support, post the topmost build error, and the call stack if relevant.
!!! A complete build log is located at '/var/tmp/portage/dev-db/libpq-8.1.8/temp/build.log'.
Comment 7 bware 2007-02-13 12:20:59 UTC
I Still have this problem with dev-db/libpq-8.1.8 on a dual Opteron box and a Athlon dual-core box.

Can any one confirm if this is 64-bit only and/or dual processor/core only?

A nasty workaround is to disable portage's sandbox. The build then works fine and seems to produce a stable output.

Comment 8 Tiziano Müller (RETIRED) gentoo-dev 2007-02-13 13:03:56 UTC
bware: It's neither of both. But it is pretty random which makes it really hard to track. But your hint with the sandbox is interesting. This would also explain why I could never reproduce it by just running the test.
Sandbox Team: Could you please take a look at this issue and tell us if there might be a connection?
Comment 9 Michael Crawford (ali3nx) 2007-02-26 22:40:43 UTC
I'll affirm this is a sandbox bug. I have tested this on 10+ systems in various arches using both stable and unstable libpq, postgresql without sandbox in features both libpq and postgresql will finish econfig. 
Comment 10 Michael Crawford (ali3nx) 2007-02-26 22:43:17 UTC
forums thread I opened related to the issue
http://forums.gentoo.org/viewtopic-t-514765-highlight-libpq.html
Comment 11 Stefan de Konink 2007-03-23 23:37:00 UTC
This is the first I noticed this on our systems. Here a Dual Opteron was used.

configure:22598: x86_64-pc-linux-gnu-gcc -o conftest -march=opteron -O2 -pipe -Wall -Wmissing-prototypes -Wpointer-arith -Winline -Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing  -pthread  -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -DIN_CONFIGURE -D_GNU_SOURCE    conftest.c -lpam -lssl -lcrypto -lz -lreadline -lcrypt -lresolv -lnsl -ldl -lm -lbsd   -lpthread    >&5
configure:22601: $? = 0
configure:22603: ./conftest
./configure: line 22604: 15474 Segmentation fault      ./conftest$ac_exeext
configure:22606: $? = 139
configure: program exited with status 139
configure: failed program was:

gcc-4.1.2
Comment 12 Jakub Moc (RETIRED) gentoo-dev 2007-05-06 14:07:51 UTC
*** Bug 177310 has been marked as a duplicate of this bug. ***
Comment 13 Mike Doty (RETIRED) gentoo-dev 2007-07-12 02:39:02 UTC
why is this still open? 8.0.9 isn't in the tree
Comment 14 Vladimir G. Ivanovic 2007-09-14 17:25:58 UTC
(In reply to comment #13)
> why is this still open? 8.0.9 isn't in the tree

FYI: On amd64, it still affects the libpq-8.2.4 build.

I "fixed" the problem by manually changing " $(use_enable threads thread-safety )" to "$(use_enable threads thread-safety-force )" in libpq-8.2.4.ebuild.

Comment 15 Kevin O'Gorman 2007-10-14 14:57:14 UTC
(In reply to comment #14)
> (In reply to comment #13)
> > why is this still open? 8.0.9 isn't in the tree
> 
> FYI: On amd64, it still affects the libpq-8.2.4 build.
> 
> I "fixed" the problem by manually changing " $(use_enable threads thread-safety
> )" to "$(use_enable threads thread-safety-force )" in libpq-8.2.4.ebuild.
> 

It's still a bug in 8.0.13 (the only x86 stable version).  I just hit it while "emerge -eav world" due to upgrading my GCC.  Now that's a nasty time to have an old package refuse to build.  I'm lucky I keep all of the gentoo list messages in a gmail account so I was able to find out quickly how to deal with it.  The above thread-safety-force trick did it for me.

If this is not a problem in the ~x86 versions, maybe somebody should request they be stabilised.

Come to think of it, why is this still marked as "NEW"???

++ kevin
Comment 16 Ben Fowler 2008-01-17 17:19:13 UTC
(In reply to comment #15)
> (In reply to comment #14)
> [ ... ]
> 
> Come to think of it, why is this still marked as "NEW"???

I think that this bug is still in, and like the other participants here, I would suspect the sandbox. In my case (PPC32), emerge offered me libpq-8.0.15 which could not be compiled by ebuild with a message about thread safety and a possibly spurious error concerning double free in glibc. Going into the directory and running configure worked OK.

I then emerge'd that library adding the NEW USE option and this worked.
Comment 17 Mark Finnegan 2008-02-14 01:01:55 UTC
I just hit this bug on libpq-8.0.15, in the "emerge -ev system" step while upgrading gcc from 3.4.6 to 4.1.2 on i686, so it's clearly still an active bug.

In the "/var/tmp/portage/dev-db/libpq-8.0.15/work/postgresql-8.0.15" directory:

Manually re-running ./configure shows:
checking allow thread-safe client libraries... no

Manually re-running the original "./configure --prefix=/usr --includedir=/usr/include/postgresql/libpq-4 --sysconfdir=/etc/postgresql --mandir=/usr/share/man --host=i686-pc-linux-gnu --with-docdir=/usr/share/doc/libpq-8.0.15 --libdir=/usr/lib --enable-depend --with-krb5 --enable-nls --with-pam --without-perl --disable-integer-datetimes --without-python --with-readline --with-openssl --without-tcl --enable-thread-safety --with-zlib" shows:
checking allow thread-safe client libraries... yes
and
checking thread safety of required library functions... yes

Full log files are available for anyone interested.

It seems clear that this is a build environment bug, not related to AMD or ia64, as I'm seeing it with a simple CFLAGS="-O2 -march=i686 -pipe". I'm going to re-run the full emerge -ev system and report back.




emerge --info follows

blackbird ~ # emerge --info
Portage 2.1.3.19 (default-linux/x86/2007.0/desktop, gcc-4.1.2, glibc-2.6.1-r0, 2.6.16-gentoo-r7 i686)
=================================================================
System uname: 2.6.16-gentoo-r7 i686 Intel(R) Pentium(R) 4 CPU 3.20GHz
Timestamp of tree: Wed, 13 Feb 2008 14:46:01 +0000
ccache version 2.4 [enabled]
app-shells/bash:     3.2_p17-r1
dev-java/java-config: 1.3.7, 2.1.4
dev-lang/python:     2.4.4-r6
dev-python/pycrypto: 2.0.1-r6
dev-util/ccache:     2.4-r7
sys-apps/baselayout: 1.12.10-r5
sys-apps/sandbox:    1.2.18.1-r2
sys-devel/autoconf:  2.13, 2.61-r1
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10
sys-devel/binutils:  2.18-r1
sys-devel/gcc-config: 1.4.0-r4
sys-devel/libtool:   1.5.24
virtual/os-headers:  2.6.23-r3
ACCEPT_KEYWORDS="x86"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=i686 -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/lib/X11/xkb /usr/share/config /var/lib/hsqldb"
CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/revdep-rebuild /etc/terminfo /etc/texmf/web2c /etc/udev/rules.d"
CXXFLAGS="-O2 -march=i686 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="ccache distlocks metadata-transfer sandbox sfperms strict unmerge-orphans userfetch"
GENTOO_MIRRORS="ftp://mirror.mcs.anl.gov/pub/gentoo/ ftp://ftp.ussg.iu.edu/pub/linux/gentoo"
LINGUAS="en en_US"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --filter=H_**/files/digest-*"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.namerica.gentoo.org/gentoo-portage"
USE="X a52 acl acpi alsa apache2 arts berkdb bitmap-fonts cairo cdr cli cracklib crypt cups dbus doc dri dvd dvdr dvdread eds emboss encode esd evo examples fam firefox fltk fortran gdbm gif gpm gstreamer gtk hal iconv ipv6 isdnlog joystick jpeg kde kerberos ldap mad midi mikmod mmx mp3 mpeg mudflap ncurses nls nptl nptlonly nsplugin ogg opengl openmp oracle oss pam pcre pdf perl pic png pppd python qt qt3 qt3support qt4 quicktime readline reflection sdl session source spell spl ssl svg tcpd threads tiff truetype truetype-fonts type1-fonts unicode usb vorbis win32codecs x86 xml xorg xv zlib" ALSA_CARDS="emu10k1 intel8x0" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="access auth auth_dbm auth_anon auth_digest authz_host alias file-cache echo charset-lite cache disk-cache mem-cache ext-filter case_filter case-filter-in filter deflate mime-magic cern-meta expires headers unique_id usertrack proxy proxy-connect proxy-ftp proxy-http info include cgi cgid dav dav-fs vhost-alias speling rewrite log_config logio env setenvif mime status autoindex asis negotiation dir imap actions userdir so" ELIBC="glibc" INPUT_DEVICES="keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en en_US" USERLAND="GNU" VIDEO_CARDS="nvidia vesa fbdev"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, MAKEOPTS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 18 John M. Drescher 2008-02-20 16:26:59 UTC
I have this same problem on libpq-8.2.6 on x86_64 with gcc-4.2.3.

configure:22967: checking thread safety of required library functions
configure:22995: x86_64-pc-linux-gnu-gcc -o conftest -O3 -march=athlon64 -fomit$
configure:22998: $? = 0
configure:23000: ./conftest
./configure: line 23001: 13155 Segmentation fault      ./conftest$ac_exeext
configure:23003: $? = 139
configure: program exited with status 139
configure: failed program was:
| /* confdefs.h.  */
Comment 19 John M. Drescher 2008-02-20 16:35:25 UTC
Hmm. It compiled fine when I used a suggestion in the forums to do that without sandbox.

FEATURES="-sandbox" emerge libpq

 # equery uses libpq
[ Searching for packages matching libpq... ]
[ Colour Code : set unset ]
[ Legend : Left column  (U) - USE flags from make.conf              ]
[        : Right column (I) - USE flags packages was installed with ]
[ Found these USE variables for dev-db/libpq-8.2.6 ]
 U I
 + + kerberos       : Adds kerberos support
 + + nls            : Adds Native Language Support (using gettext - GNU locale utilities)
 + + pam            : Adds support PAM (Pluggable Authentication Modules) - DANGEROUS to arbitrarily flip
 - - pg-intdatetime : Enables --enable-integer-datetimes configure option, which changes PG to use 64-bit integers for timestamp storage.
 + + readline       : Enables support for libreadline, a GNU line-editing library that almost everyone wants
 + + ssl            : Adds support for Secure Socket Layer connections
 + + threads        : Adds threads support for various packages. Usually pthreads
 + + zlib           : Adds support for zlib (de)compression
Comment 20 Tiziano Müller (RETIRED) gentoo-dev 2008-06-07 20:29:13 UTC
Please use dev-db/postgresql-{base,server}
There the specific test is disabled.
Comment 21 Ruslan N. Marchenko 2009-01-29 15:41:09 UTC
> Please use dev-db/postgresql-{base,server}
> There the specific test is disabled.
But libpq is prereq for server f.i.

Disabling sandbox allows to build pq for me either.
System uname: Linux-2.6.27-gentoo-r8-i686-Intel-R-_Xeon-R-_CPU_E5405_@_2.00GHz-with-glibc2.0