Sie sind auf Seite 1von 4

3/2/2011 AIXPerl - Wikis

Systems

AIXPerl
Adde d by O neSk yW a lke r, la st e dite d by O neSk yW a lke r on Fe b 17, 2011 (vie w cha nge)
La be ls: (None )

Hints and tips when using Perl


On some recent technology levels of AIX V5.3 and V6.1, Perl can fail unexpectedly with "Out of memory!" or
"Segmentation fault(coredump)" error messages. That's because Perl on those technology levels was compiled
without the -b maxdata:0x80000000 option. To confirm that the problem is indeed the maxdata option, set the
LDR_C NTRL environment variable to override the maxdata setting:

export LDR_CNTRL=MAXDATA=0x80000000 5

and run the failing Perl script again to confirm that it does not fail. If the Perl script still fails, the maxdata setting
is not causing the failure and the issue is likely with ulimits or a shortage of paging space.

Please note that the LDR_C NTRL setting above can cause issues for other executables, so running with
LDR_CNTRL set by default is not a good idea.

The AIX ldedit command can be used to patch the Perl executable to change the maxdata setting with which it
is run.

isdtest1# which perl


/usr/bin/perl
isdtest1# ls -altr /usr/bin/perl
lrwxrwxrwx 1 root system 28 Feb 04 21:21 /usr/bin/perl ->
/usr/opt/perl5/bin/perl5.8.8
isdtest1# cd /usr/opt/perl5/bin
isdtest1# ls -altr perl*
-rwxr-xr-x 1 root system 11967 Jun 03 2009 perlivp
-rwxr-xr-x 1 root system 244 Jun 03 2009 perldoc
-rwxr-xr-x 1 root system 17973 Jun 03 2009 perlcc
-rwxr-xr-x 1 root system 37295 Jun 03 2009 perlbug
-rwxr-xr-x 2 root system 147543 Jun 03 2009 perl5.8.8
-rwxr-xr-x 2 root system 147543 Jun 03 2009 perl
-rwxr-xr-x 1 root system 11967 Jun 03 2009 perlivp_64bit
-rwxr-xr-x 1 root system 37295 Jun 03 2009 perlbug_64bit
-rwxr-xr-x 2 root system 149946 Jun 03 2009 perl_64bit
-rwxr-xr-x 2 root system 149946 Jun 03 2009 perl5.8.8_64bit
-rwxr-xr-x 1 root system 17973 Jun 30 2009 perlcc_64bit
-rwxr-xr-x 1 root system 244 Jun 30 2009 perldoc_64bit
isdtest1# df -k .
Filesystem 1024-blocks Free %Used Iused %Iused Mounted on
/dev/hd2 2359296 644104 73% 40213 21% /usr
isdtest1# cp -ip perl5.8.8 perl5.8.8.patched
isdtest1# dump -ov perl5.8.8.patched

perl5.8.8.patched:

ibm.com/developerworks/…/AIXPerl?de… 1/4
3/2/2011 AIXPerl - Wikis
***Object Module Header***
# Sections Symbol Ptr # Symbols Opt Hdr Len Flags
{{ 5 0x00010eec 3022 72 0x1002}}
Flags=( EXEC DYNLOAD DEP_SYSTEM )
Timestamp = "Jun 02 03:13:37 2009"
Magic = 0x1df (32-bit XCOFF)

***Optional Header***
Tsize Dsize Bsize Tstart Dstart
0x00001da8 0x00000630 0x00000008 0x10000150 0x20000ef8

SNloader SNentry SNtext SNtoc SNdata


0x0004 0x0002 0x0001 0x0002 0x0002

TXTalign DATAalign TOC vstamp entry


0x0007 0x0003 0x200013fc 0x0001 0x2000137c

maxSTACK maxDATA SNbss magic modtype


0x00000000 0x00000000 0x0003 0x010b 1L
isdtest1# ldedit -b maxdata:0x80000000 perl5.8.8.patched
ldedit: File perl5.8.8.patched updated.
isdtest1# dump -ov perl5.8.8.patched

perl5.8.8.patched:

***Object Module Header***


# Sections Symbol Ptr # Symbols Opt Hdr Len Flags
5 0x00010eec 3022 72 0x1002
Flags=( EXEC DYNLOAD DEP_SYSTEM )
Timestamp = "Jun 02 03:13:37 2009"
Magic = 0x1df (32-bit XCOFF)

***Optional Header***
Tsize Dsize Bsize Tstart Dstart
0x00001da8 0x00000630 0x00000008 0x10000150 0x20000ef8

SNloader SNentry SNtext SNtoc SNdata


0x0004 0x0002 0x0001 0x0002 0x0002

TXTalign DATAalign TOC vstamp entry


0x0007 0x0003 0x200013fc 0x0001 0x2000137c

maxSTACK maxDATA SNbss magic modtype


0x00000000 0x80000000 0x0003 0x010b 1L
isdtest1# cd /usr/bin
isdtest1# ls -altr perl
lrwxrwxrwx 1 root system 36 Feb 04 21:21 perl ->
/usr/opt/perl5/bin/perl5.8.8
isdtest1# ln -sf /usr/opt/perl5/bin/perl5.8.8.patched perl
isdtest1# ls -altr perl
lrwxrwxrwx 1 root system 36 Feb 07 17:33 perl ->
/usr/opt/perl5/bin/perl5.8.8.patched
isdtest1#

When a 32-bit executable is compiled without maxdata, the executable's stack and data is restricted to a single
256 MB segment. Setting maxdata to 0x80000000 lifts the 256 MB restriction to 0x80000000 = 2147483648 bytes
= 2 GB, or eight 256 MB segments.
ibm.com/developerworks/…/AIXPerl?de… 2/4
3/2/2011 AIXPerl - Wikis
= 2 GB, or eight 256 MB segments.

BTW, the Getting more memory in AIX for your Java applications article has a good explanation of how maxdata
works and what it does. In the article, see Figure 1 and the text which precedes and follows it.

Another option is to run the 64-bit version of Perl, but please note that the same Perl script will consume
more virtual and real memory when run with the 64-bit version of Perl. To use the 64-bit version of Perl, change
the hash-bang line (the first in the shell script) to point to the 64-bit executable. For example:

#!/usr/opt/perl5/bin/perl5.8.8_64bit 5

My thanks to C hris Shortes (Jay C Shortes/Dallas/IBM) for pointing out that the maxdata setting overrides soft
ulimits and that AIX does not enforce the memory ulimit.

So, when running versions of Perl compiled without maxdata (the 64-bit version is typically compiled
without maxdata), it is often necessary to alter the default data ulimit:

isdtest1# ulimit -a
time(seconds) unlimited
file(blocks) 2097151
data(kbytes) 131072
stack(kbytes) 32768
memory(kbytes) 32768
coredump(blocks) 2097151
nofiles(descriptors) 2000
threads(per process) unlimited
processes(per user) unlimited
isdtest1#

In the example above, the data ulimit will restrict Perl compiled without maxdata to 131072/1024 = 128 MBs.

First, check the hard ulimits:

isdtest1# ulimit -Ha


time(seconds) unlimited
file(blocks) 2097151
data(kbytes) unlimited
stack(kbytes) 4194304
memory(kbytes) unlimited
coredump(blocks) unlimited
nofiles(descriptors) unlimited
threads(per process) unlimited
processes(per user) unlimited
isdtest1#

Then, increase the soft data ulimit:

isdtest1# ulimit -Sd 2097152


isdtest1# ulimit -a

time(seconds) unlimited
ibm.com/developerworks/…/AIXPerl?de… 3/4
3/2/2011 AIXPerl - Wikis
time(seconds) unlimited
file(blocks) 2097151
data(kbytes) 2097152
stack(kbytes) 32768
memory(kbytes) 32768
coredump(blocks) 2097151
nofiles(descriptors) 2000
threads(per process) unlimited
processes(per user) unlimited
isdtest1#

Be careful

Don't use ulimit -d 2097152, which will change the hard data ulimit. When the hard
data ulimit is changed on a userid other than root, it can only be changed to a value
lower than the current hard data ulimit. Always specify the -S flag to set the soft
ulimit. If a hard ulimit is inadvertently reduced to a value which is too low, log off and
log back on again. The new shell will revert to the default hard ulimits.

The contents of this web page solely reflect the personal views of the authors and do not necessarily
represent the views, positions, strategies or opinions of IBM or IBM management. Please use the Add
C omment link at the bottom of the page to provide feedback. Note: Until you sign up and log in (using links in the
upper right corner of this web page), you will not see the Add C omment link and you can not add a comment.

P owe re d by Atlassia n C onflue nce , the Enterprise W ik i. (Ve rsion: 2.3.3 Build:#645 Feb 13, 2007) - Bug/fea ture request -
C ontact Adm inistra tors

ibm.com/developerworks/…/AIXPerl?de… 4/4

Das könnte Ihnen auch gefallen