|
From: <sv...@va...> - 2008-05-04 11:59:04
|
Author: bart
Date: 2008-05-04 12:59:01 +0100 (Sun, 04 May 2008)
New Revision: 8005
Log:
Make sure that the return value of highest_used_stack_address() is a valid stack pointer.
Modified:
trunk/exp-drd/drd_clientreq.c
Modified: trunk/exp-drd/drd_clientreq.c
===================================================================
--- trunk/exp-drd/drd_clientreq.c 2008-05-04 08:10:24 UTC (rev 8004)
+++ trunk/exp-drd/drd_clientreq.c 2008-05-04 11:59:01 UTC (rev 8005)
@@ -91,20 +91,35 @@
{
UInt nframes;
const UInt n_ips = 10;
+ UInt i;
Addr ips[n_ips], sps[n_ips];
Addr husa;
nframes = VG_(get_StackTrace)(vg_tid, ips, n_ips, sps, 0, 0);
+ tl_assert(1 <= nframes && nframes <= n_ips);
- /* Paranoia ... */
+ /* A hack to work around VG_(get_StackTrace)()'s behavior that sometimes */
+ /* the topmost stackframes it returns are bogus (this occurs sometimes */
+ /* at least on amd64, ppc32 and ppc64). */
+
+ husa = sps[0];
+
tl_assert(VG_(thread_get_stack_max)(vg_tid)
- - VG_(thread_get_stack_size)(vg_tid) <= VG_(get_SP)(vg_tid)
- && VG_(get_SP)(vg_tid) < VG_(thread_get_stack_max)(vg_tid));
+ - VG_(thread_get_stack_size)(vg_tid) <= husa
+ && husa < VG_(thread_get_stack_max)(vg_tid));
- husa = (nframes >= 1 ? sps[nframes - 1] : VG_(get_SP)(vg_tid));
+ for (i = 1; i < nframes; i++)
+ {
+ if (sps[i] == 0)
+ break;
+ if (husa < sps[i] && sps[i] < VG_(thread_get_stack_max)(vg_tid))
+ husa = sps[i];
+ }
+
tl_assert(VG_(thread_get_stack_max)(vg_tid)
- VG_(thread_get_stack_size)(vg_tid) <= husa
&& husa < VG_(thread_get_stack_max)(vg_tid));
+
return husa;
}
|