Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 120190

Summary: postgresql is built without --enable-thread-safety
Product: Gentoo Linux Reporter: Chris Bainbridge (RETIRED) <chrb>
Component: New packagesAssignee: PgSQL Bugs <pgsql-bugs>
Status: RESOLVED FIXED    
Severity: major CC: esigra
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 129488    

Description Chris Bainbridge (RETIRED) gentoo-dev 2006-01-24 07:56:56 UTC
Trying to track down some memory corruption problems I found: http://www.linuxfromscratch.org/blfs/view/stable/server/postgresql.html and the postgresql configure flag "--enable-thread-safety". Is there any reason why this flag isn't being used in the postgresql ebuilds? Without this it would appear that stuff like php and slony will suffer from memory corruption under multi-threaded usage.
Comment 1 Masatomo Nakano (RETIRED) gentoo-dev 2006-01-28 18:20:30 UTC
USE='threads' enables the --enable-thread-safety
Comment 2 Chris Bainbridge (RETIRED) gentoo-dev 2006-01-29 04:36:07 UTC
There is no threads USE flag in postgresql-8 ebuilds, only postgresql-7:

% grep threads *.ebuild            
postgresql-7.3.10.ebuild:IUSE="doc java libg++ nls pam perl python readline ssl tcltk zlib threads selinux"
postgresql-7.3.10.ebuild:       use threads && myconf="$myconf --enable-thread-safety"
postgresql-7.3.11.ebuild:IUSE="doc java libg++ nls pam perl python readline ssl tcltk zlib threads selinux"
postgresql-7.3.11.ebuild:       use threads && myconf="$myconf --enable-thread-safety"
postgresql-7.3.12.ebuild:IUSE="doc java libg++ nls pam perl python readline ssl tcltk zlib threads selinux"
postgresql-7.3.12.ebuild:       use threads && myconf="$myconf --enable-thread-safety"
postgresql-7.3.9-r1.ebuild:IUSE="doc java libg++ nls pam perl python readline ssl tcltk zlib threads selinux"
postgresql-7.3.9-r1.ebuild:     use threads && myconf="$myconf --enable-thread-safety"
postgresql-7.4.10.ebuild:IUSE="ssl nls java python tcltk perl libg++ pam readline zlib doc pg-hier pg-vacuumdelay pg-intdatetime threads xml2 selinux"
postgresql-7.4.10.ebuild:       use threads && myconf="$myconf --enable-thread-safety"
postgresql-7.4.7-r1.ebuild:IUSE="ssl nls java python tcltk perl libg++ pam readline zlib doc pg-hier pg-vacuumdelay pg-intdatetime threads xml2 selinux"
postgresql-7.4.7-r1.ebuild:     use threads && myconf="$myconf --enable-thread-safety"
postgresql-7.4.7-r2.ebuild:IUSE="ssl nls java python tcltk perl libg++ pam readline zlib doc pg-hier pg-vacuumdelay pg-intdatetime threads xml2 selinux"
postgresql-7.4.7-r2.ebuild:     use threads && myconf="$myconf --enable-thread-safety"
postgresql-7.4.8.ebuild:IUSE="ssl nls java python tcltk perl libg++ pam readline zlib doc pg-hier pg-vacuumdelay pg-intdatetime threads xml2 selinux"
postgresql-7.4.8.ebuild:        use threads && myconf="$myconf --enable-thread-safety"
postgresql-7.4.9.ebuild:IUSE="ssl nls java python tcltk perl libg++ pam readline zlib doc pg-hier pg-vacuumdelay pg-intdatetime threads xml2 selinux"
postgresql-7.4.9.ebuild:        use threads && myconf="$myconf --enable-thread-safety"

Also for libpq I noticed this in the output:

checking allow thread-safe client libraries... no

Doesn't libpq need to be thread safe as well? It has no threads USE flag either:

% emerge -vp libpq

These are the packages that I would merge, in order:

Calculating dependencies ...done!
[ebuild   R   ] dev-db/libpq-8.0.4  -kerberos +nls -pam +readline +ssl +zlib 0 kB 
Comment 3 Chris Bainbridge (RETIRED) gentoo-dev 2006-01-31 09:16:17 UTC
As I understand it, postgresql isn't multi-threaded, so only libpq needs to be thread safe and the threads USE flag present in the postgresql-7 ebuilds is actually useless.
Comment 4 Chris Bainbridge (RETIRED) gentoo-dev 2006-04-10 07:54:23 UTC
From postgresql HISTORY:

         "libpq and ECPG applications are now fully thread-safe
          While previous libpq releases already supported threads, this
          release improves thread safety by fixing some non-thread-safe
          code that was used during database connection startup. The
          "configure" option "--enable-thread-safety" must be used to
          enable this feature."

Since this bug has been hanging around for a while and it only affects threads users, I've gone ahead and commited -r1 ebuilds for postgresql and libpq that re-add the threads use flag so that libpq and ecpg are built with thread support. I can't be bothered to fix all the older ebuilds :-/ I hope this is ok.

Note as mentioned on http://www.dbtalk.net/mailing-database-pgsql-bugs/re-bugs-general-problems-building-146015.html I've had to add the -opt package to libpq SRC_URI. It can be removed in postgresql-8.2.