Description of problem: When the binary is linked with libncurses(-lncurses), shmat() call failes with - 1 trying to attach to an allocated shared memory segment. The shared memory segment was allocated and attached by a binary "a". shmat() was called by a binary "b" using the same shmid and shmkey and the same attached address returned by binary "a". The problem does not reproduce when the binary "b" was not linked with libncurses. Version-Release number of selected component (if applicable): How reproducible: every time Steps to Reproduce: 1.compile binary a (gcc3 -o a a.c) 2.compile binary b with -lncurses (gcc3 -o b b.c -lncurses) 3.run b with the address from a Actual results: 0xffffffffffffffff from b Expected results: valid address Additional info: a.c: ----- #include <stdio.h> #include <sys/types.h> #include <sys/shm.h> main() { unsigned int segsize = 512*1024; int shmid; key_t shmkey = 123456789; void * adr; shmid = shmget(shmkey, segsize,IPC_CREAT|0660); adr = shmat(shmid, 0,0); printf("shmid = %d adr = %p\n",shmid, adr); } b.c: ----- #include <stdio.h> #include <stdlib.h> #include<sys/types.h> #include <sys/shm.h> main(int argc, char **argv) { void * addr1, * addr2; key_t shmkey = 123456789; int shmid; addr1 = (void*) strtoul(argv[1],NULL,0); shmid = shmget(shmkey, 0, 0660); addr2 = shmat(shmid, addr1, 0); printf("addr2 = %p\n",addr2); } %gcc3 -o a a.c %gcc3 -o b b.c %gcc3 -o c b.c -lncurses % ./a shmid = 313556996 adr = 0x2000000000300000 %./b 0x2000000000300000 addr2 = 0x2000000000300000 %./c 0x2000000000300000 addr2 = 0xffffffffffffffff
kernel version is kernel-2.14.18-e.12
does this happen also when you actually use a supported gcc version ?
i could also reproduce with the gcc version 2.96-112.7.2 I have downloaded gcc3 from the rhn.redhat.com and we are using that currently.
RHEL2.1 is currently accepting only critical security fixes. This issue is outside the current scope of support.