On Thu, 2008-10-09 at 21:27 -0700, CAI Qian wrote:
> 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
> 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]>
Thanks Cai. I hope this will be helpful to everybody. Tested & Merged.
Regards--
Subrata
>
> --- 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
-------------------------------------------------------------------------
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