Bug 73092 - [patch] Unbreak WINE for 5.x and 6 [patches for both kern and port]
Summary: [patch] Unbreak WINE for 5.x and 6 [patches for both kern and port]
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 5.3-BETA7
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-24 21:10 UTC by amistry
Modified: 2006-07-22 17:30 UTC (History)
1 user (show)

See Also:


Attachments
wine-mmap.patch (305 bytes, patch)
2004-10-24 21:10 UTC, amistry
no flags Details | Diff
file.diff (1.24 KB, patch)
2004-10-24 21:10 UTC, amistry
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description amistry 2004-10-24 21:10:10 UTC
	Versions of WINE after May 2004 no longer work with FreeBSD.  This is 
due to WINE being unable to mmap part of the process address space to load in 
the Windows executables.  The reason this happens is because FreeBSD only allows
anonymously mmaping the upper part of the process address space after the
reserved data sections.

Fix: The attached patch for vm_mmap.c will allow the mmap() syscall to be
able to anonymously mmap free areas of the process address space below the
reserved area.  The wine mmap.c patch removes the reserving of the DOS area
thus allowing the correct executable load location to be used.
	
How-To-Repeat: 	Build a version of WINE after May 2004 and try to run a program.
Comment 1 amistry 2004-11-16 01:20:34 UTC
The wine-mmap.patch is no longer needed since that code has been #ifdef'd 
out in the wine CVS.
-- 
Anish Mistry
amistry@am-productions.biz
AM Productions http://am-productions.biz/
Comment 2 Simon 'corecode' Schubert 2004-11-18 04:51:49 UTC
I was looking at getting a current wine running on DragonFly and found 
your patch. In my opinion, this patch fixes the "problem" at the wrong 
place:

wine doesn't want arbitary addresses (mmap(NULL...)), but wants 
addresses below user_space_limit. Although mmap(2) doesn't provide such 
a rich set of features to be able to specify an "desired/allowed 
range", this can be easily done in wine itself:

diff -ru work/wine-20041019/dlls/ntdll/virtual.c 
work.old/wine-20041019/dlls/ntdll/virtual.c
--- work/wine-20041019/dlls/ntdll/virtual.c	2004-10-11 
22:59:06.000000000 +0200
+++ work.old/wine-20041019/dlls/ntdll/virtual.c	2004-11-18 
04:33:04.000000000 +0100
@@ -119,6 +119,7 @@
  /* Note: these are Windows limits, you cannot change them. */
  # define ADDRESS_SPACE_LIMIT  ((void *)0xc0000000)  /* top of the 
total available address space */
  # define USER_SPACE_LIMIT     ((void *)0x80000000)  /* top of the user 
address space */
+# define LOW_SPACE_LIMIT      ((void *)0x110000)    /* lower address 
space limit */
  #else
  static UINT page_shift;
  static UINT page_mask;
@@ -600,7 +601,7 @@

          for (;;)
          {
-            if ((ptr = wine_anon_mmap( NULL, view_size, 
VIRTUAL_GetUnixProt(vprot), 0 )) == (void *)-1)
+            if ((ptr = wine_anon_mmap( LOW_SPACE_LIMIT, view_size, 
VIRTUAL_GetUnixProt(vprot), 0 )) == (void *)-1)
              {
                  if (errno == ENOMEM) return STATUS_NO_MEMORY;
                  return STATUS_INVALID_PARAMETER;

Just ask mmap to start allocating at a low address. It's not tested a 
lot, but applications run again.

cheers
   simon

-- 
/"\
\ /
  \     ASCII Ribbon Campaign
/ \  Against HTML Mail and News
Comment 3 Gerald Pfeifer freebsd_committer freebsd_triage 2004-12-12 19:24:42 UTC
State Changed
From-To: open->feedback

I have integrated Simon's patch into the emulators/wine port.  Is there 
still something we may want to address in general, in the FreeBSD kernel 
or libc, or shall we close this PR? 

(If it's the former, would you mind suggesting an appropriate subject for 
the PR to catch the attention of the relevant folks?)
Comment 4 Gerald Pfeifer freebsd_committer freebsd_triage 2004-12-13 12:30:36 UTC
State Changed
From-To: feedback->closed

Okay, so it seems we can close this.
Comment 5 Michael Nottebrock freebsd_committer freebsd_triage 2006-07-22 00:32:28 UTC
IMHO this issue still isn't fixed completely. A good deal of applications=20
still fail to run in wine on FreeBSD while they do work on Linux, due to=20
memory allocation issues, the most prominent being Internet Explorer:

[lofi@kiste]:0:~ >winedbg "/home/lofi/.ies4linux/ie6/drive_c/Program Files/Internet Explorer/IEXPLORE.EXE"
err:heap:HEAP_CreateSystemHeap system heap base address 0x80000000 not available
WineDbg starting on pid 0xa
fixme:dbghelp:SymLoadModule Should have successfully loaded debug information
for image c:\windows\system32\iexplore.exe
fixme:dbghelp:SymLoadModule Should have successfully loaded debug information
for image c:\windows\system32\iexplore.exe
err:heap:HEAP_CreateSystemHeap system heap base address 0x80000000 not available
fixme:dbghelp:SymLoadModule Should have successfully loaded debug information
for image c:\windows\system32\winex11.drv
fixme:dbghelp:SymLoadModule Should have successfully loaded debug information
for image c:\windows\system32\imm32.dll
fixme:actctx:CreateActCtxW 0x35fb40 00000008
fixme:actctx:ActivateActCtx 0xf00baa 0x35f908
fixme:dbghelp:SymLoadModule Should have successfully loaded debug information
for image c:\windows\system32\uxtheme.dll
fixme:actctx:DeactivateActCtx 00000000 00f00bad
file_set_error: Bad address
file_set_error: Bad address
0x9c23eddd: subl        $12,%esp

What's worse - this bug, if reported in wine's bugtracker, either gets misidentified as a duplicate of=20
http://www.freebsd.org/cgi/query-pr.cgi?pr=3Dports/76459 or ignored as a
FreeBSD-specific issue that requires attention of people with expertise with
FreeBSD's memory management (which is probably true).
Comment 6 Michael Nottebrock freebsd_committer freebsd_triage 2006-07-22 17:28:53 UTC
Also ref.: http://bugs.winehq.org/show_bug.cgi?id=5732