|
From: Julian S. <js...@ac...> - 2010-09-08 10:40:53
|
Umm, I must say, I don't think this is a good solution. Yes, it means
that this specific call of VG_TRACK( die_mem_stack, ... ) does not send
a zero length to drd_stop_using_mem. But there are other places where
die_mem_stack and related functions (new_mem_*) are sent to tools, and
we would have to audit all of those call sites too. The interface never
promised that such functions would not be called with len == 0.
It would I think be better for all the places that such a notification
could be sent to (eg, drd_stop_using_mem) to be robust to a len == 0
value.
I can see you possibly did this for performance related reasons,
to remove a conditional branch. I think you can achieve the same
without making the assumption "len != 0" by doing this
void drd_stop_using_mem(const Addr a1, const SizeT len,
const Bool is_stack_mem)
{
const Addr a2 = a1 + len;
if (UNLIKELY(a1 >= a2)) {
if (len == 0) return;
tl_assert(0);
}
... code as before ..
}
You still have only one conditional branch on the fast path,
and the slow path differentiates the len == 0 case (harmless)
from the wraparound case (we must assert).
J
On Wednesday, September 08, 2010, Christian Borntraeger wrote:
> Am 07.09.2010 18:48, schrieb Bart Van Assche:
> >> If the environment happens to be the right size,
> >> (the_iifii.initial_client_SP - VG_STACK_REDZONE_SZB) might be exactly
> >> on a page start and therefore identical to seg-start. This would
> >> result in len=0, no?
> >>
> >> (coincidentally seen here on my system).
> >
> > Thanks for the feedback. Does r11342 (or later) work on your system
> > without triggering an assertion failure ?
>
> Yes, that patch also solves my problem. Thanks
>
> Christian
>
>
> ---------------------------------------------------------------------------
> --- This SF.net Dev2Dev email is sponsored by:
>
> Show off your parallel programming skills.
> Enter the Intel(R) Threading Challenge 2010.
> http://p.sf.net/sfu/intel-thread-sfd
> _______________________________________________
> Valgrind-developers mailing list
> Val...@li...
> https://lists.sourceforge.net/lists/listinfo/valgrind-developers
|