Hi,

This patch adds some debug messages when shmat(2) failed, so we could tell if 
the failure was
because the requested address space has been used. In addition, it fixes the 
output of failed
error code to a more meaningful form. The sample output is,

./shmem_test_06: IPC Shared Memory TestSuite program

        mykey to uniquely identify the shared memory segment 0x330f017c

        Get shared memory segment (1048576 bytes)

        Attach shared memory segment to process

        Shared memory segment address : 0x20000000 

        Index through shared memory segment ...

        mykey to uniquely identify the shared memory segment 0x340f017c

        Get shared memory segment (1048576 bytes)

        Attach shared memory segment to process

        Shared memory segment address : 0x30000000 

        Index through shared memory segment ...

        mykey to uniquely identify the shared memory segment 0x350f017c

        Get shared memory segment (1048576 bytes)

        Attach shared memory segment to process

        Shared memory segment address : 0x48000000 

        Index through shared memory segment ...

        mykey to uniquely identify the shared memory segment 0x360f017c

        Get shared memory segment (1048576 bytes)

        Attach shared memory segment to process

        Shared memory segment address : 0x50000000 

        Index through shared memory segment ...

        mykey to uniquely identify the shared memory segment 0x370f017c

        Get shared memory segment (1048576 bytes)

        Attach shared memory segment to process

        Shared memory segment address : 0x60000000 

        Index through shared memory segment ...

        mykey to uniquely identify the shared memory segment 0x380f017c

        Get shared memory segment (1048576 bytes)

        Attach shared memory segment to process

        Shared memory segment address : 0x70000000 

        Index through shared memory segment ...

        mykey to uniquely identify the shared memory segment 0x390f017c

        Get shared memory segment (1048576 bytes)

        Attach shared memory segment to process

        Shared memory segment address : 0x80000000 

        Index through shared memory segment ...

        mykey to uniquely identify the shared memory segment 0x410f017c

        Get shared memory segment (1048576 bytes)

        Attach shared memory segment to process

        Shared memory segment address : 0x90000000 

        Index through shared memory segment ...

        mykey to uniquely identify the shared memory segment 0x420f017c

        Get shared memory segment (1048576 bytes)

        Attach shared memory segment to process

        Shared memory segment address : 0xa0000000 

        Index through shared memory segment ...

        mykey to uniquely identify the shared memory segment 0x430f017c

        Get shared memory segment (1048576 bytes)

        Attach shared memory segment to process

        Shared memory segment address : 0xb0000000 

        Index through shared memory segment ...

        mykey to uniquely identify the shared memory segment 0x450f017c

        Get shared memory segment (1048576 bytes)

        Attach shared memory segment to process
heap 0x2428000
00400000-00402000 r-xp 00000000 08:13 258511                            
/home/qcai/buffer/ltp/testcases/kernel/ipc/ipc_stress/shmem_test_06
00601000-00602000 rw-p 00001000 08:13 258511                            
/home/qcai/buffer/ltp/testcases/kernel/ipc/ipc_stress/shmem_test_06
20000000-20100000 rw-s 00000000 00:08 51445777                           
/SYSV330f017c (deleted)
30000000-30100000 rw-s 00000000 00:08 51478546                           
/SYSV340f017c (deleted)
48000000-48100000 rw-s 00000000 00:08 51511316                           
/SYSV350f017c (deleted)
50000000-50100000 rw-s 00000000 00:08 51544087                           
/SYSV360f017c (deleted)
60000000-60100000 rw-s 00000000 00:08 51576856                           
/SYSV370f017c (deleted)
70000000-70100000 rw-s 00000000 00:08 51609625                           
/SYSV380f017c (deleted)
80000000-80100000 rw-s 00000000 00:08 51642394                           
/SYSV390f017c (deleted)
90000000-90100000 rw-s 00000000 00:08 51675163                           
/SYSV410f017c (deleted)
a0000000-a0100000 rw-s 00000000 00:08 51707932                           
/SYSV420f017c (deleted)
b0000000-b0100000 rw-s 00000000 00:08 51740701                           
/SYSV430f017c (deleted)
3e18200000-3e18220000 r-xp 00000000 08:11 61856                          
/lib64/ld-2.8.90.so
3e1841f000-3e18420000 r--p 0001f000 08:11 61856                          
/lib64/ld-2.8.90.so
3e18420000-3e18421000 rw-p 00020000 08:11 61856                          
/lib64/ld-2.8.90.so
3e19600000-3e1976c000 r-xp 00000000 08:11 61857                          
/lib64/libc-2.8.90.so
3e1976c000-3e1996c000 ---p 0016c000 08:11 61857                          
/lib64/libc-2.8.90.so
3e1996c000-3e19970000 r--p 0016c000 08:11 61857                          
/lib64/libc-2.8.90.so
3e19970000-3e19971000 rw-p 00170000 08:11 61857                          
/lib64/libc-2.8.90.so
3e19971000-3e19976000 rw-p 3e19971000 00:00 0 
3e1a200000-3e1a217000 r-xp 00000000 08:11 61865                         
/lib64/libpthread-2.8.90.so
3e1a217000-3e1a416000 ---p 00017000 08:11 61865                         
/lib64/libpthread-2.8.90.so
3e1a416000-3e1a417000 r--p 00016000 08:11 61865                         
/lib64/libpthread-2.8.90.so
3e1a417000-3e1a418000 rw-p 00017000 08:11 61865                         
/lib64/libpthread-2.8.90.so
3e1a418000-3e1a41c000 rw-p 3e1a418000 00:00 0 
7fa1d2e5a000-7fa1d2e5c000 rw-p 7fa1d2e5a000 00:00 0 
7fa1d2e6c000-7fa1d2e6f000 rw-p 7fa1d2e6c000 00:00 0 
7fffdae59000-7fffdae6e000 rw-p 7ffffffea000 00:00 0                      [stack]
7fffdaffe000-7fffdafff000 r-xp 7fffdaffe000 00:00 0                      [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  
[vsyscall]
ERROR [line: 212] shmat failed - return: -1: Invalid argument

This patch should be applied on the top of another patch I sent earlier with 
title "shmem_test_06
Failed with Stack Randomization". Tested successfully on a x86_64 machine.

Cai Qian

Signed-off-by: CAI Qian <[EMAIL PROTECTED]>

--- shmem_test_06.c.orig        2008-10-10 11:36:15.022862741 +0800
+++ shmem_test_06.c     2008-10-10 12:25:45.473862020 +0800
@@ -202,7 +202,13 @@
 
       if ((long)(shmptr[i] = (char *) shmat (shmid[i], (const void*)offset, 
0)) == -1)
        {
-         sprintf(tmpstr, "shmat failed - return: %p", shmptr[i]);
+         /* If shmat(2) failed, we need the currect process address
+            space layout to debug. The failure can be random. */
+         sprintf (tmpstr, "cat /proc/%d/maps >&2", (int) getpid ());
+         fprintf (stderr, "heap %p\n", sbrk (0));
+         system (tmpstr);
+
+         sprintf(tmpstr, "shmat failed - return: %ld", (long)shmptr[i]);
          sys_error (tmpstr, __LINE__);
        }
 


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to