https://bugs.winehq.org/show_bug.cgi?id=56161
Bug ID: 56161 Summary: MapViewOfFile3 alignment and/or NtMapViewOfSection(Ex) alignment strictness Product: Wine Version: 9.0-rc4 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: ntdll Assignee: wine-bugs@winehq.org Reporter: jan.felix.muenchhalfen@rwth-aachen.de Distribution: ---
Hi,
scenario: .net 7 core self-contained bundle exe (about 180mb) relevant log:
1751.909:011c:0120:Ret KERNEL32.VirtualFree() retval=00000001 ret=1404f06f5 1751.909:011c:0120:Call kernelbase.MapViewOfFile3(0000012c,ffffffffffffffff,024b0000,021eb000,00001000,6fff00004000,00000002,00000000,00000000) ret=1404f0544 1751.909:011c:0120:Call ntdll.NtMapViewOfSectionEx(0000012c,ffffffffffffffff,0019df08,0019df00,0019df40,00004000,100000002,00000000,ffffffff00000000) ret=6fffff455a9f 1751.909:011c:0120:trace:virtual:NtMapViewOfSectionEx handle=0x12c process=0xffffffffffffffff addr=0x24b0000 off=21eb000 size=1000 access=2 1751.909:011c:0120:Ret ntdll.NtMapViewOfSectionEx() retval=c0000220 ret=6fffff455a9f 1751.909:011c:0120:Call ntdll.RtlNtStatusToDosError(c0000220) ret=6fffff455ab6 1751.909:011c:0120:Ret ntdll.RtlNtStatusToDosError() retval=0000046c ret=6fffff455ab6 1751.909:011c:0120:Ret kernelbase.MapViewOfFile3() retval=00000000 ret=1404f0544 1751.909:011c:0120:Call KERNEL32.GetLastError() ret=1402c8e0a 1751.909:011c:0120:Ret KERNEL32.GetLastError() retval=0000046c ret=1402c8e0a 1751.909:011c:0120:Call ntdll.RtlAllocateHeap(001c0000,00000000,00000018) ret=1402c598b 1751.909:011c:0120:trace:heap:RtlAllocateHeap handle 00000000001C0000, flags 0, size 0x18, return 00000000012D7F10, status 0. 1751.909:011c:0120:Ret ntdll.RtlAllocateHeap() retval=012d7f10 ret=1402c598b 1751.909:011c:0120:Call ntdll.RtlPcToFileHeader(14076c100,0019df20) ret=1405a0ee2 1751.909:011c:0120:Ret ntdll.RtlPcToFileHeader() retval=140000000 ret=1405a0ee2 1751.909:011c:0120:Call KERNEL32.RaiseException(e06d7363,00000001,00000004,0019df28) ret=1405a0f28 1751.909:011c:0120:trace:seh:dispatch_exception code=e06d7363 flags=1 addr=00006FFFFF423C47 ip=6fffff423c47 1751.909:011c:0120:trace:seh:dispatch_exception info[0]=0000000019930520 1751.909:011c:0120:trace:seh:dispatch_exception info[1]=000000000019dfb8 1751.909:011c:0120:trace:seh:dispatch_exception info[2]=000000014076c100 1751.909:011c:0120:trace:seh:dispatch_exception info[3]=0000000140000000 1751.909:011c:0120:warn:seh:dispatch_exception EXCEPTION_WINE_CXX_EXCEPTION exception (code=e06d7363) raised
note the return value by NtMapViewOfSectionEx being c0000220 (ERROR_MAPPED_ALIGNMENT)
Bug: MapViewOfFile3 should according to the docs round down the address to 64k alignment. I believe it does not in wine.
Topic for Discussion: this code runs on windows. We suspect that windows is not adhering fully to what's on msdn, and lets things with just Pagesize-Alignment go unharmed. I do not really know how you would proceed with this, just letting you know, you will probably have a better idea than me what to do about it. I just tested patching the alignment requirement to 4k instead of 64k in NtMapViewOfSectionEx and then the self-contained exe just runs fine.
You can see the sourcecode responsible for it here (https://github.com/dotnet/runtime/blob/f21dc6c3dceb6ea76bef73e2a026c770aaed3...)
They align (round down) both address and offset into filehandle to page-size.
According to msdn they are supposed to use 64k alignment. We are posting a bug report for the dotnet team for this, too.