Re: AIX Permission weirdness

From: Seneca Cunningham <scunning(at)ca(dot)afilias(dot)info>
To: Chris Browne <cbbrowne(at)acm(dot)org>
Cc: pgsql-ports(at)postgresql(dot)org
Subject: Re: AIX Permission weirdness
Date: 2005-12-02 18:29:38
Message-ID: 43909292.4070106@ca.afilias.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-ports

Chris Browne wrote:
> We recently ran into fairly weird regressions on AIX. Shared
> libraries wouldn't load, which assortedly meant that:
> - plpgsql couldn't be loaded
> - Slony-I stored functions couldn't work
> - regression tests wouldn't work
>
> The typical result:
>
> -bash-3.00$ /opt/dbs/pgsql748-afilias-AIX53-2005-10-19/bin/createlang plpgsql template1
> ERROR: could not load library "/opt/dbs/pgsql748-afilias-AIX53-2005-10-19/lib/plpgsql.so": A memory address is not in the address space for the process.
> createlang: language installation failed: ERROR: could not load library "/opt/dbs/pgsql748-afilias-AIX53-2005-10-19/lib/plpgsql.so": A memory address is not in the address space for the process.
>
> The evident problem is actually on the permissions...

The cause of the problem ended up being the default 32-bit memory model
on AIX. The quick workarounds are chmoding all the libs to 755 and
building postgres with the linker flag "-bmaxdata:0x40000000".

> After modifying plpgsql.so to have "777" permissions (which was
> doubtless more open than necessary, but hey, it took 2 seconds to
> think of it :-)), the library loaded in fine.

The 777 mode let plpgsql.so load because when the other-read bit is set,
the dlopened library is loaded into the shared library text segment.
When the bit is unset and the library isn't already in shared memory,
dlopen tries to load the library into private memory. The default model
only allows for part of a single 256M segment to be the user heap and it
is too full to allow plpgsql.so to be dlopened into it.

The previously mentioned option "-bmaxdata:0x40000000" causes the heap
to be moved out of the process private segment and is instead allocated
four segments (1G) of memory, reducing the amount of memory available to
the process as shared memory to 1.75G. The first digit of the maxdata
arg can be changed to a maximum of 8, and is the number of segments
allocated to the heap at the expense of segments for shared memory.

References:
"Developing and Porting C and C++ Applications on AIX"
Section 2.6: Dynamic loading
(book page 82, pdf page 108)
Section 2.9: Shared libraries in a development environment
(book page 99, pdf page 125)
Section 3.2: The 32-bit user process model
(book page 109, pdf page 135)
http://www.redbooks.ibm.com/redbooks/pdfs/sg245674.pdf
http://www.redbooks.ibm.com/abstracts/sg245674.html?Open

"Large Program Support"
http://publib.boulder.ibm.com/infocenter/pseries/topic/com.ibm.aix.doc/aixprggd/genprogc/lrg_prg_support.htm

--
Seneca Cunningham
scunning(at)ca(dot)afilias(dot)info

In response to

Browse pgsql-ports by date

  From Date Subject
Next Message Tom Lane 2005-12-02 18:32:42 Re: [HACKERS] Should libedit be preferred to libreadline?
Previous Message Bruce Momjian 2005-12-02 18:23:35 Re: [HACKERS] Should libedit be preferred to libreadline?