bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug in setting initial brk?


From: John Reiser
Subject: bug in setting initial brk?
Date: Sun, 27 May 2001 18:13:22 -0700

The code in sysdeps/unix/sysv/linux/dl-sysdep.c:39

    __sbrk (_dl_pagesize - ((&_end - (void *) 0) & _dl_pagesize));

does not match the corresponding elf/dl-minimal.c:63

      alloc_end = (void *) 0 + (((alloc_ptr - (void *) 0) + _dl_pagesize - 1)
                                & ~(_dl_pagesize - 1));

because the " - 1" has been omitted in two places.  As written,
frob_brk() adjusts the break by either 0 or 4K (depending whether
&_end is on an odd page or an even page), instead of by
the distance up to a page boundary.  The "clever" way to compute
the distance is

        ((void *)0 - &_end) & (_dl_pagesize - 1)

-- 
John Reiser, address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]