https://bugs.winehq.org/show_bug.cgi?id=48665
Bug ID: 48665 Summary: Legends of Runeterra crashes at launch with wine-staging 5.2 (regression) Product: Wine Version: 5.2 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: ntdll Assignee: wine-bugs@winehq.org Reporter: aguertin+wine@aguertin.net Regression SHA1: 64d70b103d65198614973e38422aec210db92360 Distribution: Gentoo
Legends of Runeterra crashes at startup with wine-staging 5.2. It worked fine in wine-staging 5.1
Bisecting shows that it works with wine 0a66eaea68 staging 14a3242
and fails with wine f909d18baf staging c26be86c4
That narrows it down to the MemoryWorkingSetExInformation changes. The changes that went into wine are different from what staging had: staging just had a stub for MemoryWorkingSetExInformation, whereas live now has an implementation.
Gentoo x86_64 No relevant terminal output
https://bugs.winehq.org/show_bug.cgi?id=48665
aguertin+wine@aguertin.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Blocks| |45667 Keywords| |regression
https://bugs.winehq.org/show_bug.cgi?id=48665
Andrew Wesie awesie@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |awesie@gmail.com
--- Comment #1 from Andrew Wesie awesie@gmail.com --- I haven't tested Runeterra yet, but I wanted to add some context to the Wine patch.
The staging patch was a hack that reported all memory as invalid. Since LoL (and I'm guessing Runeterra as well) only check that memory is properly marked as invalid, this worked. However, it broke another program (bug 48268).
The tests that were committed as part of this patch set have some TODOs, e.g. there are known problems with the current implementation. Unfortunately, it is difficult to efficiently mirror the exact behavior of Windows without modifications to the Linux kernel. It would be interesting to know if one of those tests already cover this case or not.
For reference, here is a link to a blog post that may be relevant: https://www.triplefault.io/2017/08/detecting-debuggers-by-abusing-bad.html.
https://bugs.winehq.org/show_bug.cgi?id=48665
--- Comment #2 from Andrew Wesie awesie@gmail.com --- Confirmed the issue. It is a known limitation that is annoying to handle correctly in Wine.
When a DLL is mapped in to memory, its data section should be mapped as PAGE_WRITECOPY and this memory should be reported as "Shared" by QueryWorkingSetEx. Once a page is modified, that page should become mapped as PAGE_READWRITE and reported as not shared.
Wine does not handle this correctly. Wine maps PROT_WRITECOPY as a private mapping (instead of a shared mapping) and does not update the mapping protection to PROT_READWRITE.
Provided we do not want to modify the Linux kernel, the correct way to handle this is probably to map the memory read only, then handle the fault by mapping it as PAGE_READWRITE. Unfortunately, this may harm start-up performance due to the extra page faults.
https://bugs.winehq.org/show_bug.cgi?id=48665
--- Comment #3 from Andrew Wesie awesie@gmail.com --- Created attachment 66571 --> https://bugs.winehq.org/attachment.cgi?id=66571 Fix using ntdll-WRITECOPY staging patchset.
I used the existing ntdll-WRITECOPY staging patchset to hopefully fix Runeterra. Please test and report if it helps.
I had to make some improvements to the ntdll-WRITECOPY staging patchset because it has problems and was disabled by default.
https://bugs.winehq.org/show_bug.cgi?id=48665
--- Comment #4 from Dmitry Timoshkov dmitry@baikal.ru --- (In reply to Andrew Wesie from comment #3)
Created attachment 66571 [details] Fix using ntdll-WRITECOPY staging patchset.
+static void segv_handler_early( int signal, siginfo_t *siginfo, void *sigcontext ) +{ + ucontext_t *ucontext = sigcontext; + + switch(TRAP_sig(ucontext)) + { + case TRAP_x86_PAGEFLT: /* Page fault */ + if (!virtual_handle_fault( siginfo->si_addr, (ERROR_sig(ucontext) >> 1) & 0x09, TRUE )) + return; + break; + /* fall-through */ + default: + WINE_ERR( "Got unexpected trap %lld during process initialization\n", TRAP_sig(ucontext) ); + abort_thread(1); + break; + } +}
Looks like a typo and /* fall-through */ is never true due to 'break;'.
https://bugs.winehq.org/show_bug.cgi?id=48665
Georg georg.schuemann@web.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |georg.schuemann@web.de
--- Comment #5 from Georg georg.schuemann@web.de --- (In reply to Andrew Wesie from comment #3)
I used the existing ntdll-WRITECOPY staging patchset to hopefully fix Runeterra. Please test and report if it helps.
I can confirm that legends of runeterra is working with this patch on wine-staging5.4
https://bugs.winehq.org/show_bug.cgi?id=48665
--- Comment #6 from aguertin+wine@aguertin.net --- (In reply to Andrew Wesie from comment #3)
Created attachment 66571 [details] Fix using ntdll-WRITECOPY staging patchset.
I used the existing ntdll-WRITECOPY staging patchset to hopefully fix Runeterra. Please test and report if it helps.
I can also confirm that this fixes the problem with wine-staging-5.5. Thank you!
https://bugs.winehq.org/show_bug.cgi?id=48665
David Torok dt@zeroitlab.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |dt@zeroitlab.com
--- Comment #7 from David Torok dt@zeroitlab.com --- (In reply to Andrew Wesie from comment #3)
Created attachment 66571 [details] Fix using ntdll-WRITECOPY staging patchset.
I used the existing ntdll-WRITECOPY staging patchset to hopefully fix Runeterra. Please test and report if it helps.
I had to make some improvements to the ntdll-WRITECOPY staging patchset because it has problems and was disabled by default.
Thanks for this Andrew, impressive work! :) The last remaining issue I see is that the gameclient seems to disconnect from the server, roughly every 3 minutes. (It's initiated by the client, because it seems to think the connection timed out, even though it did not as I confirmed to have received packets with a reverse proxy shortly before the timeout)
https://bugs.winehq.org/show_bug.cgi?id=48665
--- Comment #8 from aguertin+wine@aguertin.net --- This is fixed with staging d33cdb84 (https://github.com/wine-staging/wine-staging/commit/d33cdb84fd8fed24e3a9ce89...) which looks to be the same as comment 3.
Thanks!
https://bugs.winehq.org/show_bug.cgi?id=48665
Andrew Wesie awesie@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #66571|0 |1 is obsolete| |
--- Comment #9 from Andrew Wesie awesie@gmail.com --- Created attachment 67095 --> https://bugs.winehq.org/attachment.cgi?id=67095 Alternative fix using soft dirty PTEs
After adding the previous patch to wine-staging, it became clear that it is unlikely to be a path forward due to the limitations of using mmap+sigsegv to implement WRITECOPY. In the future, it may be possible to use userfaultfd but not currently.
This alternative patches tries to achieve the same effects that this bug requires. It is not perfect, e.g. there are some unfixable race conditions and performance overhead, but it shouldn't break anything unlike the previous attempt.
https://bugs.winehq.org/show_bug.cgi?id=48665
Zebediah Figura z.figura12@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |z.figura12@gmail.com Summary|Legends of Runeterra |Legends of Runeterra |crashes at launch with |crashes at launch (needs |wine-staging 5.2 |proper WRITECOPY emulation) |(regression) |
https://bugs.winehq.org/show_bug.cgi?id=48665
soredake gi85qht0z@relay.firefox.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |gi85qht0z@relay.firefox.com
https://bugs.winehq.org/show_bug.cgi?id=48665
François Gouget fgouget@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch CC| |fgouget@codeweavers.com
https://bugs.winehq.org/show_bug.cgi?id=48665
soredake broaden_acid002@simplelogin.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC|broaden_acid002@simplelogin | |.com |