virtual memory problems with Linux 2.4.5

lawson_whitney at juno.com lawson_whitney at juno.com
Tue Jun 12 20:54:32 CDT 2001



On Tue, 12 Jun 2001 lawson_whitney at juno.com wrote:

>
> Not only does it look like it could easily be a misaligned mmap, Mike's
> little patch makes the crash go away.  Using mmap instead of mmap64 or
> using kernel 2.2.14 instead of 2.4.5 also takes away the crash.
> Sorry the config test doesn't seem to catch it - it looks as if it
> should.  I will take a better look at some debugmsgs and straces after
> supper.

Couldn't catch it with strace, but the attached ugly patch caught these
troublesome mmaps:

trace:module:PE_LoadImage loading C:\iv\I_view32.exe
trace:virtual:CreateFileMappingA (14,(nil),01000000,0000000000000000,(null))
trace:module:map_image mapped PE file at 0x400000-0x4bf000
View: 00400000 - 004befff 28
      00400000 - 004befff c-rw-
trace:module:map_image mapping section .text at 0x401000 off 400 size 77400 flags 60000020
trace:virtual:VIRTUAL_mmap setoff 0x401000 77400 7 12 9 400 = 0x401000
trace:module:map_image mapping section .rdata at 0x479000 off 77800 size ec00 flags 40000040
trace:virtual:VIRTUAL_mmap setoff 0x479000 ec00 7 12 9 77800 = 0x479000
trace:module:map_image mapping section .data at 0x488000 off 86400 size b000 flags c0000040
trace:virtual:VIRTUAL_mmap setoff 0x488000 b000 7 12 9 86400 = 0x488000
trace:module:map_image mapping section .idata at 0x4ab000 off 91400 size 1a00 flags c0000040
trace:virtual:VIRTUAL_mmap setoff 0x4ab000 1a00 7 12 9 91400 = 0x4ab000
trace:module:map_image mapping section .rsrc at 0x4ad000 off 92e00 size 12000 flags 40000040

trace:module:PE_LoadImage loading C:\away\bin\juno.exe
trace:virtual:CreateFileMappingA (14,(nil),01000000,0000000000000000,(null))
trace:module:map_image mapped PE file at 0x400000-0x4bc000
View: 00400000 - 004bbfff 28
      00400000 - 004bbfff c-rw-
trace:module:map_image mapping section .text at 0x401000 off 400 size 68c00 flags 60000020
trace:virtual:VIRTUAL_mmap setoff 0x401000 68c00 7 12 9 400 = 0x401000
trace:module:map_image mapping section .rdata at 0x46a000 off 69000 size 18200 flags 40000040
trace:module:map_image mapping section .data at 0x483000 off 81200 size f000 flags c0000040
trace:module:map_image mapping section .rsrc at 0x494000 off 90200 size 28000 flags 40000040

This looks sort of like a kernel bug, doesn't it?  Do I want to try to
find it?

Lawson
---cut---
-------------- next part --------------
diff -ur was/memory/virtual.c is/memory/virtual.c
--- was/memory/virtual.c	Fri May 11 07:03:48 2001
+++ is/memory/virtual.c	Tue Jun 12 21:33:00 2001
@@ -664,6 +664,9 @@
 
     if (fd == -1) return wine_anon_mmap( start, size, prot, flags );
 
+    /* Linux 2.4.x seems not to return EINVAL for non-aligned offsets */
+    if(!(offset&page_mask))
+    {
     if ((ret = mmap( start, size, prot, flags, fd, offset )) != (LPVOID)-1)
         return ret;
 
@@ -681,8 +684,12 @@
 #ifdef MAP_PRIVATE
         if (!(flags & MAP_PRIVATE)) return ret;
 #endif
-    }
-
+        }
+    } else     if ((ret = mmap( start, size, prot, flags, fd, offset )) != (LPVOID)-1)
+     { 
+     TRACE("setoff %p %x %x %x %d %x = %p\n", start, size, prot,flags, fd, offset, ret);
+     munmap(ret, size);
+     }
     /* Reserve the memory with an anonymous mmap */
     ret = wine_anon_mmap( start, size, PROT_READ | PROT_WRITE, flags );
     if (ret == (LPVOID)-1) return ret;


More information about the wine-devel mailing list