Re: Bug in mremap()? was: Re: Bug in realloc ????? (glibc2.1.2)

From: Andreas Jaeger (aj@suse.de)
Date: Wed Feb 02 2000 - 14:01:12 EST


>>>>> Wolfram Gloger writes:

WG> Hello,
>> I have attached a small program, hopefully enough documented.
>> (No makefile, because no options are used).

WG> [program demonstrating running out of address space with just
WG> realloc() of relatively small chunks of memory, eventually
WG> the stack and an mmapped region overlap]

>> I hope this helps to find out if this "feature"
>> is our problem or it is definitly a kernel/libc problem.

WG> Very nice test program, thanks !

WG> IMHO, it is a kernel bug. Your first message was a bit unclear about
WG> how much stack space you require, but with the test program, it is
WG> obvious that you can get the `overlap' effect even when you use very
WG> little stack space (as you should in a well-behaved program :-).

WG> realloc() in glibc-2 employs the Linux-specific mremap() system call
WG> with the MREMAP_MAYMOVE flag, which gives the kernel complete freedom
WG> about where to reallocate the (expanded, in your test case) chunk.
WG> The Linux kernel seems to prefer to move the chunk towards higher and
WG> higher addresses. I think it should rather place it somewhere where
WG> interference with the stack is less likely, just like when calling
WG> mmap(0, ...) without the MAP_FIXED argument. Below is an untested
WG> patch for Linux-2.0.x which is likely to fix the problem. Maybe this
WG> is already fixed in 2.3.x, but I doubt it.
It's not fixed in 2.3.x.

We've to differentiate two problems here (as Andrea already
explained):
- mremap using higher and higher addresses
- the stack growing in the heap

Even if mremap is fixed, the `overlap' shouldn't happen. Andrea is
currently looking into this.

Andreas

P.S. Folks on linux-kernel who want to read the whole thread, can read
the initial messages on bug-glibc via the archives at
http://sourceware.cygnus.com/glibc/.

-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.rhein-neckar.de

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Feb 07 2000 - 21:00:08 EST