http://bugs.winehq.org/show_bug.cgi?id=20331
Summary: VirtualAlloc() should allocate addresses low to high Product: Wine Version: 1.1.31 Platform: PC URL: http://rh-software.com/ OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: ntdll AssignedTo: wine-bugs@winehq.org ReportedBy: ray@pobox.co.uk
Currently when VirtualAlloc() is called with a NULL address high addresses are sometimes returned rather than low addresses. Looking at http://msdn.microsoft.com/en-us/library/aa366887(VS.85).aspx you will see there is the MEM_TOP_DOWN option to specify that high addresses should be used, thus when this is not specified low addresses should be used. This is the situation on Windows NT4 through to Server 2008 R2/Windows 7.
To show this effect download http://rh-software.com/downloads/siv.zip, extract the files and issue the command: wine siv -save=[memory]=stdout which on my system gives: [memory] [windows]
Area Start Address Limit Address Size Size Proportion Elapsed MB/sec
0 0x02B80000 0x67F80000 0x65400000 1.58GB 54.95% 0.010 1 0x7F000000 0x7FC00000 0x00C00000 12.00MB 0.41% 0.005 2 0x7FFF0000 0x81FF0000 0x02000000 32.00MB 1.09% 0.005 3 0xB75C0000 0xB79C0000 0x00400000 4.00MB 0.14% 0.005 4 0xB6CA0000 0xB70A0000 0x00400000 4.00MB 0.14% 0.005 5 0xB6890000 0xB6C90000 0x00400000 4.00MB 0.14% 0.005 ...
I think this may only show the issue for systems with >= 3.5GB of ram. I am wondering if it might be related to addresses > 0x80000000 (signed vs. unsigned tests). Note that SIV is linked with /largeaddressaware.
http://bugs.winehq.org/show_bug.cgi?id=20331
Dmitry Timoshkov dmitry@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Alias|VirtualAlloc |
http://bugs.winehq.org/show_bug.cgi?id=20331
--- Comment #1 from Alexandre Julliard julliard@winehq.org 2009-10-12 04:10:55 --- Low addresses are returned until we run out of low address space. After that we use the system default policy. If your app really depends on this (why?) you'd have to tweak the linux kernel policy.
http://bugs.winehq.org/show_bug.cgi?id=20331
--- Comment #2 from ray@pobox.co.uk 2009-10-12 05:58:38 --- Created an attachment (id=24048) --> (http://bugs.winehq.org/attachment.cgi?id=24048) Full save from Wine/Linux
http://bugs.winehq.org/show_bug.cgi?id=20331
--- Comment #3 from ray@pobox.co.uk 2009-10-12 05:59:06 --- Created an attachment (id=24049) --> (http://bugs.winehq.org/attachment.cgi?id=24049) Full save frim Windows XP
http://bugs.winehq.org/show_bug.cgi?id=20331
--- Comment #4 from ray@pobox.co.uk 2009-10-12 06:22:30 --- (In reply to comment #1)
Low addresses are returned until we run out of low address space. After that we use the system default policy. If your app really depends on this (why?) you'd have to tweak the linux kernel policy.
What is "low address space" ? Hi guess is addresses < 0x80000000.
I have attached the full save from Linux and looking at the end you will see:
292 0x68630000 0x68A30000 0x00400000 4.00MB 0.14% 0.005 293 0x68220000 0x68620000 0x00400000 4.00MB 0.14% 0.005 294 0xB7FD0000 0xBF7D0000 0x07800000 120.00MB 4.07% 0.005
Total 0x02B80000 0xBF7D0000 0xB8400000 2.88GB 124.00MB 1.486
which shows low addresses at the end, but why is entry 295 0xB7FD0000 at the end ?
If you look at the attached results from a Windows XP system you will see that the addresses increse all the time. The panel is working out which parts of the virtual address space is available. Because Wine does not operate the same as Windows my code does not work. Looking at http://www.microsoft.com/whdc/system/platform/server/PAE/PAEdrv.mspx I found: Test using the MEM_TOP_DOWN registry setting This forces all allocations for memory to be allocated from the top down, instead of the normal bottom up. Set HKLM\System\CurrentControlSet\Control\Session Manager\Memory Management\AllocationPreference REG_DWORD = 0x100000 which confirms that by default low addresses should be allocated before high addresses.
I could change SIV to try and work-a-round this, but feel this is an incorrrect solution given the fact that Wine should return low addresses before high addresses. I also feel having to change the Linux kernel is inappropiate. I feel Wine would tell Linux to allocate low to high.
http://bugs.winehq.org/show_bug.cgi?id=20331
--- Comment #5 from Alexandre Julliard julliard@winehq.org 2009-10-12 07:11:15 --- What is considered low addresses depend on the preloader allocations. You can play with the WINEPRELOADRESERVE variable if you want to change that range.
The rest of the memory is under control of the kernel, that's required for Unix libraries to be able to allocate memory. I don't quite understand why you have to depend on the order of allocation to determine the available memory (and of course that may break on Windows too, cf. the registry key you mentioned).
http://bugs.winehq.org/show_bug.cgi?id=20331
--- Comment #6 from ray@pobox.co.uk 2009-10-12 07:46:51 --- SIV does not work as expected when running under Wine. This is caused by Wine not allocating low addresses before high addresses.
There are 2 possible solutions: 1) Wine is fixed to operate the same as Windows 2) I change my code to program round this.
When I initially started using Wine I was led to believe that I should not "work-a-round" bugs in Wine, I should raise bugs and get Wine fixed, assuming this is still true I feel that 1) is the sensible resolution. Are you going to fix Wine ?
http://bugs.winehq.org/show_bug.cgi?id=20331
--- Comment #7 from ray@pobox.co.uk 2009-10-12 07:47:09 --- (In reply to comment #5) I only discovered AllocationPreference today and am considering what to do about this. I have searched the wine source for "AllocationPreference" and not been able to find it, thus I assume Wine does not implement this. Would you like me to add a new Bugzilla entry stating Wine should ?
http://bugs.winehq.org/show_bug.cgi?id=20331
--- Comment #8 from Alexandre Julliard julliard@winehq.org 2009-10-12 08:19:06 --- (In reply to comment #6)
SIV does not work as expected when running under Wine. This is caused by Wine not allocating low addresses before high addresses.
There are 2 possible solutions:
- Wine is fixed to operate the same as Windows
- I change my code to program round this.
When I initially started using Wine I was led to believe that I should not "work-a-round" bugs in Wine, I should raise bugs and get Wine fixed, assuming this is still true I feel that 1) is the sensible resolution. Are you going to fix Wine ?
Probably not, because that would break many more important things. So yes, in general fixing Wine is the answer, but when we get into low-level details there will necessarily be differences that can't be resolved. So for apps that depend on that sort of low-level behavior (copy protection is another example), the only remaining approach is to fix the app, or just accept that it won't work on Wine.
http://bugs.winehq.org/show_bug.cgi?id=20331
--- Comment #9 from Alexandre Julliard julliard@winehq.org 2009-10-12 08:21:25 --- (In reply to comment #7)
(In reply to comment #5) I only discovered AllocationPreference today and am considering what to do about this. I have searched the wine source for "AllocationPreference" and not been able to find it, thus I assume Wine does not implement this. Would you like me to add a new Bugzilla entry stating Wine should ?
Only if you can find a real application that breaks because it's not implemented. That seems pretty unlikely.
http://bugs.winehq.org/show_bug.cgi?id=20331
--- Comment #10 from ray@pobox.co.uk 2009-10-12 09:53:06 --- (In reply to comment #8)
Probably not
OK, I have done a work-a-round which was actually less work than reporting the bug in Wine !
SIV 4.02 now typically reports:
Area Start Address Limit Address Size Size Proportion
0 0x018D0000 0x67CD0000 0x66400000 1.60GB 54.83% 1 0x682F0000 0x7BEF0000 0x13C00000 316.00MB 10.59% 2 0x7C3F0000 0x7CFF0000 0x00C00000 12.00MB 0.40% 3 0x7F000000 0x7FC00000 0x00C00000 12.00MB 0.40% 4 0x7FFF0000 0x81FF0000 0x02000000 32.00MB 1.07% 5 0x821E0000 0xB79E0000 0x35800000 856.00MB 28.69% 6 0xB7FB0000 0xBF7B0000 0x07800000 120.00MB 4.02%
Total 0x018D0000 0xBF7B0000 0xBA800000 2.91GB 88.00MB
Should you choose to correct Wine one day then you could use http://rh-software.com/downloads/zip/siv_v4.01.zip to test the fix.
I feel this entry should me marked as confirmed, as from what has been said this clearly the situation.
What should be done with this Bugzilla entry ?
Is there a list of known differences ?, should this be added ?
http://bugs.winehq.org/show_bug.cgi?id=20331
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download
http://bugs.winehq.org/show_bug.cgi?id=20331
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |WONTFIX
--- Comment #11 from Alexandre Julliard julliard@winehq.org 2009-10-12 10:13:15 --- Since you have a workaround and there is no other known app where it's a problem, it's a wontfix for now. It can be reopened if we find another app that needs it.
http://bugs.winehq.org/show_bug.cgi?id=20331
Vitaliy Margolen vitaliy@kievinfo.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #12 from Vitaliy Margolen vitaliy@kievinfo.com 2009-10-12 20:29:08 --- Closing