]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix boundary case when trying to use brk() to expand right up to the
authorTom Hughes <tom@compton.nu>
Wed, 21 Jun 2006 08:01:14 +0000 (08:01 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 21 Jun 2006 08:01:14 +0000 (08:01 +0000)
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

coregrind/m_syswrap/syswrap-generic.c

index d52dddb6d6f5570b53583841322b9b507f12aa9f..ebb8d0578e5fb29aa18f317e561d655ee6ffa1ab 100644 (file)
@@ -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));