From: Tom Hughes Date: Wed, 21 Jun 2006 08:01:14 +0000 (+0000) Subject: Fix boundary case when trying to use brk() to expand right up to the X-Git-Tag: svn/VALGRIND_3_3_0~735 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e8a28708cabd34f7c15ef9354b2b76f0cb823d6;p=thirdparty%2Fvalgrind.git Fix boundary case when trying to use brk() to expand right up to the limit of the brk segment. Because VG_(brk_limit) is the first address beyond the end of the memory available to the caller of brk() we need to allow it to grow up to and including the address one page below the end of the space valgrind has reserved. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5974 --- diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index d52dddb6d6..ebb8d0578e 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -989,14 +989,14 @@ static Addr do_brk ( Addr newbrk ) return newbrk; } - if (newbrk >= rseg->end+1 - VKI_PAGE_SIZE) { + if (newbrk > rseg->end+1 - VKI_PAGE_SIZE) { /* request is too large -- the resvn would fall below 1 page, which isn't allowed. */ goto bad; } newbrkP = VG_PGROUNDUP(newbrk); - vg_assert(newbrkP > rseg->start && newbrkP < rseg->end+1 - VKI_PAGE_SIZE); + vg_assert(newbrkP > rseg->start && newbrkP <= rseg->end+1 - VKI_PAGE_SIZE); delta = newbrkP - rseg->start; vg_assert(delta > 0); vg_assert(VG_IS_PAGE_ALIGNED(delta));