Wine and mmap

Brian Fundakowski Feldman green at
Fri Aug 27 21:24:08 PDT 2004

On Sat, Aug 28, 2004 at 02:09:36PM +1000, John Birrell wrote:
> On Sat, Aug 28, 2004 at 12:01:18AM -0400, Brian Fundakowski Feldman wrote:
> > Is the problem that it specifically runs out of memory area but it's not
> > checking where it needs to?  If so, I think you could hash out the solution
> > with a wrapper/workaround mmap() in userland first.
> The problem is that if the mmap kernel code is left to choose a map address,
> it tries to use memory above the highest value allocated. This conflicts with
> Wine because Wine needs to reserve the top half of a process' address space
> to be compatible with Win9X programs.
> Wine gobbles the upper memory as soon as it can (i.e. just after the base
> Wine process is loaded with it's linked libraries - libc). Once the memory
> has been reserved, Wine then goes ahead and loads the "DLL" libraries using
> the standard dlopen() call. The first one Wine tries to load fails because
> the upper-most address used by that time is the top of the process address
> space and it all ends in tears.
> What the mmap code needs (IMHO) to do is to find a hole in the address space
> if the upper memory is all allocated.

Cool, sounds like a wrapper to mmap() that takes care of this for every
BSD by allocating 1MB of memory (for i386/amd64 4GB address space compat(?))
and mincore() all possible address space on it then choosing the right area
itself....  getpagesize() and mincore() (and doing it in a thread-safe
manner) can fix this temporarily for all BSDs in the WINE code, I'd think.

Brian Fundakowski Feldman                           \'[ FreeBSD ]''''''''''\
  <> green at                               \  The Power to Serve! \
 Opinions expressed are my own.                       \,,,,,,,,,,,,,,,,,,,,,,\

More information about the freebsd-current mailing list