AIX has some issues that applications developers need to be aware of.
Problem: A 32 bit process drops core with SIGSEGV or SIGILL.
If this never occurs on other systems like Linux or BSD, it is almost certainly a consequence of the default 256MB segment limit for 32-bit applications, see 32-bit-process-memory-models. In case the link disappears, here is the relevant quote:
"[The] default memory model is one where data and heap share the same 256MB segment. The heap pointer grows down to the data pointer and the data pointer grows up to the heap pointer. When they collide the program goes down with a SEGV."
First, check the maxdata section of the executable. In this case, it has the low 256MB default value for data and stack.
dump -ov runtest maxSTACK maxDATA SNbss magic modtype 0x00000000 0x00000000 0x0003 0x010b 1L |
Solution 1: Set maxdata at link time:
# gcc LDFLAGS=-Wl,-bmaxdata:0x80000000 # xlc LDFLAGS=-bmaxdata:0x80000000 |
Solution 2: Edit maxdata in the binary:
ldedit -b maxdata:0x80000000 runtest |
Solution 3: Set the LDR_CNTRL environment variable for all processes in the current shell:
export LDR_CNTRL=MAXDATA=0x80000000 |
Problem: A 64 bit process gets SIGKILL or freezes the machine.
In principle, this can occur on all systems with overallocation. However, unlike other systems, AIX permits extreme overallocation. Example:
$ cat << EOF > alloc.c > #include <stdio.h> > #include <stdlib.h> > > > int > main(void) > { > char *c = malloc(1125899906842624ULL); > if (c == NULL) { > fprintf(stderr, "refuse to allocate 1125899906842624 bytes\n"); > return 0; > } > > return 0; > } > EOF $ $ gcc -maix64 -O0 -o alloc alloc.c $ $ # NOTE: this can also freeze the machine $ ./alloc Killed |
For 64-bit processes the default is unlimited maxdata. The solutions are the same as above, except that in this case maxdata is decreased rather than increased:
$ LDR_CNTRL=MAXDATA=0x8000000000 ./alloc refuse to allocate 1125899906842624 bytes $ $ ldedit -b maxdata:0x8000000000 alloc ldedit: File alloc updated. $ ./alloc refuse to allocate 1125899906842624 bytes $ $ gcc -Wl,-bmaxdata:0x8000000000 -maix64 -O0 -o alloc alloc.c $ ./alloc refuse to allocate 1125899906842624 bytes |