|
From: Adishesh M <adi...@gm...> - 2012-08-15 17:48:03
|
Hi,
i will test using patch and update the test results soon.
Since previous mail was mangled, resending it.
I have used below program for testing. Below are the steps I have followed.
Compile: gcc -g3 test_shm.c -o test_shm
Create shared memory: ./test_shm –c
Get shared memory without valgrind: ./test_shm –g ( this works fine)
Get with valgrind: /usr/bin/valgrind --tool=memcheck --leak-check=full
--track-origins=yes --log-file=/tmp/val_log /home/rtp99/test_shm –g
With valgrind shmat command fails.
Total shared memory segments active on the my system is 320.
My process will attach to 40 shared memory segments. Shmat will fails
when tested with 14 shared memory attach also.
Total RAM available on my system is 124GB. I am using HP C7000 blade
hardware with RHEL6.2 OS.
I am using 64bit binary. 'file test_shm' command output is
test_shm: ELF 64-bit LSB executable, x86-64, version 1 (SYSV),
dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not
stripped
Thanks and regards,
Adishesh
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdio.h>
#include <unistd.h>
struct shm_details
{
key_t key;
size_t size;
int shmid;
void *shm;
};
main(int argc,char **argv)
{
int i;
struct shm_details test_shm[] =
{
{0xe300626d,2147456,-1,NULL },
{0xe300626c ,144271608 ,-1,NULL},
{0xe300626e,115604 ,-1,NULL},
{0xe300626f ,118376704 ,-1,NULL},
{0xe300653d ,574592 ,-1,NULL},
{0xe300653c ,22578504 ,-1,NULL},
{0xe300653e ,18092 ,-1,NULL},
{0xe300653f ,208416960 ,-1,NULL},
{0xe30066b9 ,2147456 ,-1,NULL},
{0xe30066b8 ,120870984 ,-1,NULL},
{0xe30066ba ,484260 ,-1,NULL},
{0xe30066bb ,9793648960 ,-1,NULL},
{0xe30068ad ,8438912,-1,NULL },
{0xe30068ac,553973472,-1,NULL}
};
int list = (sizeof(test_shm)/sizeof(test_shm[0]));
int shmflg;
int delete=0;
struct shmid_ds buf;
if(argc != 2)
{
printf("Usage: ./test_shm -c|-g|-d\n -c for create shared memory\n
-g for get shared memory\n -d delete the shared memory\n");
return(0);
}
if(strcmp(argv[1],"-c") == 0)
{
shmflg = IPC_CREAT | 0666;
}else if(strcmp(argv[1],"-g") == 0)
{
shmflg = 0666;
}else if(strcmp(argv[1],"-d") == 0)
{
shmflg = 0666;
delete = 1;
}else{
printf("Usage: ./test_shm -c|-g|-d\n -c for create\n -g for get
shared memory\n -d delete the shared memory\n");
return(0);
}
for (i=0;i<list;i++)
{
if ((test_shm[i].shmid = shmget(test_shm[i].key,
test_shm[i].size,shmflg)) < 0)
{
perror("shmget");
printf("ERROR: shmget failed for shmkey=0x%x\n", test_shm[i].key);
return(1);
}
}
/*delete*/
if(delete == 1)
{
for (i=0;i<list;i++)
{
if(shmctl(test_shm[i].shmid, IPC_RMID, &buf) != 0){
perror("shmctl");
printf("ERROR: shmctl failed for shmkey=0x%x\n", test_shm[i].key);
return(1);
}
}
printf("INFO: All shared memories are deleted\n");
return(0);
}
/* Now we attach the segment to our data space. */
for (i=0;i<list;i++)
{
if((test_shm[i].shm = shmat(test_shm[i].shmid, 0, 0)) == (char *) -1){
perror("shmat");
printf("ERROR: shmat failed for shmkey=0x%x\n", test_shm[i].key);
return(1);
}
}
for (i=0;i<list;i++)
{
if(shmdt(test_shm[i].shm) !=0 ) {
perror("shmat");
printf("ERROR: shmdt failed for shmkey=0x%x\n", test_shm[i].key);
return(1);
}
}
printf("INFO: exit success\n");
return(0);
}
>Can you try again after applying the attached patch ?
>Thanks
>Philippe
|