[Bug 44038] RPCS3 emulator crashes due to 'kernel32.SetFileInformationByHandle' lacking support of 'FileEndOfFileInfo' info class

WineHQ Bugzilla wine-bugs at winehq.org
Wed Feb 3 16:43:12 CST 2021


https://bugs.winehq.org/show_bug.cgi?id=44038

Anastasius Focht <focht at gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|RPCS3 emulator crashes      |RPCS3 emulator crashes due
                   |after exit                  |to
                   |                            |'kernel32.SetFileInformatio
                   |                            |nByHandle' lacking support
                   |                            |of 'FileEndOfFileInfo' info
                   |                            |class
      Fixed by SHA1|                            |1d36532d2277046872fa39ff3a8
                   |                            |1d9dc84e27d5a
                URL|https://ci.appveyor.com/api |https://web.archive.org/web
                   |/buildjobs/xiund8hfaj7j16eh |/20210203211500/https://git
                   |/artifacts/rpcs3-v0.0.4-201 |hub.com/RPCS3/rpcs3-binarie
                   |7-11-14-9e0b881b_win64.zip  |s-win/releases/download/bui
                   |                            |ld-7b5dcd9d6a27d922de3d5292
                   |                            |bb4ff290bf426fd7/rpcs3-v0.0
                   |                            |.5-6906-7b5dcd9d_win64.7z
             Status|NEW                         |RESOLVED
                 CC|                            |focht at gmx.net
         Resolution|---                         |FIXED
          Component|-unknown                    |kernel32

--- Comment #5 from Anastasius Focht <focht at gmx.net> ---
Hello folks,

this is fixed by commit
https://source.winehq.org/git/wine.git/commitdiff/1d36532d2277046872fa39ff3a81d9dc84e27d5a
("kernelbase: Support FileEndOfFileInfo in SetFileInformationByHandle.").

Thanks Jacek

The old download link was gone:

https://ci.appveyor.com/api/buildjobs/xiund8hfaj7j16eh/artifacts/rpcs3-v0.0.4-2017-11-14-9e0b881b_win64.zip

The oldest RPCS3 snapshot still available for reproduce:

https://rpcs3.net/compatibility?b&p=88

971 days ago (2018-06-08)  0.0.5-6906

https://github.com/RPCS3/rpcs3-binaries-win/releases/download/build-7b5dcd9d6a27d922de3d5292bb4ff290bf426fd7/rpcs3-v0.0.5-6906-7b5dcd9d_win64.7z

I've created a stable snapshot via Internet Archive:

https://web.archive.org/web/20210203211500/https://github.com/RPCS3/rpcs3-binaries-win/releases/download/build-7b5dcd9d6a27d922de3d5292bb4ff290bf426fd7/rpcs3-v0.0.5-6906-7b5dcd9d_win64.7z

Starting and exiting the app doesn't trigger a crash. You actually have to do
something. I could reliably trigger a crash using following recipe:

1) select 'Manage' in main menu
2) select 'Virtual File System'
3) click 'Add New Directory' button
4) select existing directory in browse dialog
5) click 'Okay' button
6) profit!

Before the fix:

--- snip ---
$ WINEDEBUG=+seh,+relay,+ntdll wine ./rpcs3.exe >>log.txt 2>&1
...
0104:Call KERNEL32.SetFilePointerEx(00000118,00000000,02bb4f48,00000000)
ret=00467228
0104:Call
ntdll.NtSetInformationFile(00000118,02bb4e58,02bb4e48,00000008,0000000e)
ret=7b01d4e8
0104:Ret  ntdll.NtSetInformationFile() retval=00000000 ret=7b01d4e8
0104:Ret  KERNEL32.SetFilePointerEx() retval=00000001 ret=00467228
0104:Call
KERNEL32.SetFileInformationByHandle(00000118,00000006,02bb4f40,00000008)
ret=00467bc2
0104:fixme:file:SetFileInformationByHandle 0000000000000118, 6,
0000000002BB4F40, 8
0104:Ret  KERNEL32.SetFileInformationByHandle() retval=00000000 ret=00467bc2
0104:Call KERNEL32.GetLastError() ret=00467bcc
0104:Ret  KERNEL32.GetLastError() retval=00000078 ret=00467bcc
...
0104:Call ucrtbase.__std_exception_copy(02bb4e60,02bb4e78) ret=004615b2
0104:trace:seh:__std_exception_copy (0000000002BB4E60 0000000002BB4E78)
...
0104:Ret  ucrtbase.__std_exception_copy() retval=089d6301 ret=004615b2
0104:Call ucrtbase._CxxThrowException(02bb4e70,01d998e0) ret=004615cf
...
0104:Call KERNEL32.RaiseException(e06d7363,00000001,00000004,02bb4da0)
ret=02be980d
0104:Call ntdll.memcpy(02bb4c80,02bb4da0,00000020) ret=7b012a13
0104:Ret  ntdll.memcpy() retval=02bb4c80 ret=7b012a13
0104:trace:seh:dispatch_exception code=e06d7363 flags=1 addr=000000007B012A22
ip=000000007B012A22 tid=0104
0104:trace:seh:dispatch_exception  info[0]=0000000019930520
0104:trace:seh:dispatch_exception  info[1]=0000000002bb4e70
0104:trace:seh:dispatch_exception  info[2]=0000000001d998e0
0104:trace:seh:dispatch_exception  info[3]=0000000000010000
0104:trace:seh:dispatch_exception  rax=0000000002bb4c80 rbx=00000000086752f8
rcx=0000000002bb4c60 rdx=0000000000000036
0104:trace:seh:dispatch_exception  rsi=0000000000000004 rdi=0000000002bb4d30
rbp=0000000002bb4cc0 rsp=0000000002bb4c40
0104:trace:seh:dispatch_exception   r8=0000000000000000  r9=0000000000000000
r10=0000000002bb4781 r11=0000000000000000
0104:trace:seh:dispatch_exception  r12=0000000008c6fda0 r13=0000000008c71160
r14=0000000000000000 r15=0000000008c6fda0 
--- snip ---

After the fix:

--- snip ---
...
0104:Call KERNEL32.GetFileSizeEx(000000d8,02bbf5b0) ret=004672c3
0104:Call
ntdll.NtQueryInformationFile(000000d8,02bbf4e8,02bbf4d0,00000018,00000005)
ret=7b01c3e0
0104:Ret  ntdll.NtQueryInformationFile() retval=00000000 ret=7b01c3e0
0104:Ret  KERNEL32.GetFileSizeEx() retval=00000001 ret=004672c3
0104:Call KERNEL32.SetFilePointerEx(000000d8,00000000,02bbf5b8,00000000)
ret=00467228
0104:Call
ntdll.NtSetInformationFile(000000d8,02bbf4c8,02bbf4b8,00000008,0000000e)
ret=7b01d4f8
0104:Ret  ntdll.NtSetInformationFile() retval=00000000 ret=7b01d4f8
0104:Ret  KERNEL32.SetFilePointerEx() retval=00000001 ret=00467228
0104:Call KERNEL32.ReadFile(000000d8,02bbf710,00000000,02bbf5c0,00000000)
ret=00466795
0104:Call
ntdll.NtReadFile(000000d8,00000000,00000000,00000000,02bbf4b0,02bbf710,00000000,00000000,00000000)
ret=7b01618d
0104:Ret  ntdll.NtReadFile() retval=00000000 ret=7b01618d
0104:Ret  KERNEL32.ReadFile() retval=00000001 ret=00466795
... 
--- snip ---

Reference of 'FileEndOfFileInfo' info class in RPCS3 sources:

https://github.com/RPCS3/rpcs3/search?q=FileEndOfFileInfo

https://github.com/RPCS3/rpcs3/blob/78bad361ab46b03866468ac4d0415ddf71438c6d/Utilities/File.cpp#L822

--- snip ---
bool fs::truncate_file(const std::string& path, u64 length)
{
    if (auto device = get_virtual_device(path))
    {
        return device->trunc(path, length);
    }

#ifdef _WIN32
    // Open the file
    const auto handle = CreateFileW(to_wchar(path).get(), GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
    if (handle == INVALID_HANDLE_VALUE)
    {
        g_tls_error = to_error(GetLastError());
        return false;
    }

    FILE_END_OF_FILE_INFO _eof;
    _eof.EndOfFile.QuadPart = length;

    if (!SetFileInformationByHandle(handle, FileEndOfFileInfo, &_eof,
sizeof(_eof)))
    {
        g_tls_error = to_error(GetLastError());
        CloseHandle(handle);
        return false;
    }

    CloseHandle(handle);
    return true;
#else
    if (::truncate(path.c_str(), length) != 0)
    {
        g_tls_error = to_error(errno);
        return false;
    }

    return true;
#endif
}
--- snip ---

$ sha1sum rpcs3-v0.0.5-6906-7b5dcd9d_win64.7z
be33bc5002f37dbaa853a981df53c14862365686  rpcs3-v0.0.5-6906-7b5dcd9d_win64.7z

$ du -sh rpcs3-v0.0.5-6906-7b5dcd9d_win64.7z
16M    rpcs3-v0.0.5-6906-7b5dcd9d_win64.7z

$ wine --version
wine-6.1-122-g2201ca08fb0

Regards

-- 
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.


More information about the wine-bugs mailing list