https://bugs.winehq.org/show_bug.cgi?id=42982
Bug ID: 42982 Summary: Bayonetta can`t save settings Product: Wine Version: 2.7 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs@winehq.org Reporter: zentarim@rambler.ru Distribution: Ubuntu
Created attachment 58119 --> https://bugs.winehq.org/attachment.cgi?id=58119 file trace
Bayonetta can`t save settings. Game try to write settings to file ~/documents/Bayonetta/system_data, but fails and freezes. If this "garbage" file is exists - game does not start. file have size ~ 1.7Kb.
Log (trace+file) in attachement. Suspicious lines 135820 - 135825:
trace:file:ReadFile 0xb0 0x33f3d0 857 0x33f7d4 (nil) trace:file:CreateFileW L"C:\users\zentarim\\041c\043e\0438 \0434\043e\043a\0443\043c\0435\043d\0442\044b/Bayonetta/system_data" GENERIC_READ creation 3 attributes 0x40000080 trace:file:RtlDosPathNameToNtPathName_U (L"C:\users\zentarim\\041c\043e\0438 \0434\043e\043a\0443\043c\0435\043d\0442\044b/Bayonetta/system_data",0x33faa8,(nil),(nil)) trace:file:RtlGetFullPathName_U (L"C:\users\zentarim\\041c\043e\0438 \0434\043e\043a\0443\043c\0435\043d\0442\044b/Bayonetta/system_data" 520 0x33f7e8 (nil)) trace:file:wine_nt_to_unix_file_name L"\users\zentarim\\041c\043e\0438 \0434\043e\043a\0443\043c\0435\043d\0442\044b\Bayonetta\system_data" not found in /home/zentarim/.PlayOnLinux//wineprefix/Bayonetta/dosdevices/c:/users/zentarim/Мои документы/Bayonetta trace:file:CreateFileW returning 0xffffffff
$ ls -lah '/home/zentarim/.PlayOnLinux//wineprefix/Bayonetta/dosdevices/c:/users/zentarim/Мои документы/Bayonetta/system_data' -rw-rw-r-- 1 zentarim zentarim 1,7K мая 9 20:42 /home/zentarim/.PlayOnLinux//wineprefix/Bayonetta/dosdevices/c:/users/zentarim/Мои документы/Bayonetta/system_data
https://bugs.winehq.org/show_bug.cgi?id=42982
Zentarim zentarim@rambler.ru changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |zentarim@rambler.ru
https://bugs.winehq.org/show_bug.cgi?id=42982
--- Comment #1 from Zentarim zentarim@rambler.ru --- This game is exists in Wine appdb: https://appdb.winehq.org/objectManager.php?sClass=version&iId=35150
https://bugs.winehq.org/show_bug.cgi?id=42982
fjfrackiewicz@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |fjfrackiewicz@gmail.com
--- Comment #2 from fjfrackiewicz@gmail.com --- (In reply to Zentarim from comment #0)
/home/zentarim/.PlayOnLinux//wineprefix/Bayonetta/dosdevices/c:/users/ zentarim/Мои документы/Bayonetta trace:file:CreateFileW returning 0xffffffff
$ ls -lah '/home/zentarim/.PlayOnLinux//wineprefix/Bayonetta/dosdevices/c:/users/ zentarim/Мои документы/Bayonetta/system_data' -rw-rw-r-- 1 zentarim zentarim 1,7K мая 9 20:42 /home/zentarim/.PlayOnLinux//wineprefix/Bayonetta/dosdevices/c:/users/ zentarim/Мои документы/Bayonetta/system_data
Can you try the game in a clean Wine prefix without PlayOnLinux? The reason I ask is because PlayOnLinux is not supported by the Wine project.
https://bugs.winehq.org/show_bug.cgi?id=42982
--- Comment #3 from Zentarim zentarim@rambler.ru --- Created attachment 58149 --> https://bugs.winehq.org/attachment.cgi?id=58149 trace v2
Unfortunately i can run game on clean prefix only on wine-2.7-staging. Hope this does not matter. The game behavior not changed, error in place.
https://bugs.winehq.org/show_bug.cgi?id=42982
--- Comment #4 from Zentarim zentarim@rambler.ru --- In order to get rid of Cyrillic characters and spaces, i tried to change documents directory name from 'Мои документы' to 'documents' via regedit and winecfg. But it did not help. Maybe this info will help you.
https://bugs.winehq.org/show_bug.cgi?id=42982
Toni eldrad@autistici.org changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |eldrad@autistici.org
--- Comment #5 from Toni eldrad@autistici.org --- Created attachment 58626 --> https://bugs.winehq.org/attachment.cgi?id=58626 Alternative1: Perform synced but set STATUS_PENDING error
The patch sets the STATUS_PENDING error for operations requesting asynchronous execution.
This allows bayonetta to detect the operation as done, since the program requests asynchronous operation and seems to just check for success by checking on STATUS_PENDING windows error with GetLastError
See Alternative2 for a full async fix
https://bugs.winehq.org/show_bug.cgi?id=42982
--- Comment #6 from Toni eldrad@autistici.org --- Created attachment 58627 --> https://bugs.winehq.org/attachment.cgi?id=58627 Alternative2: Do read/write really asynchronous
This patch makes file read/write operations requested as asynchronous to be really done asynchronous so programs expecting the status_pending error flag to be set have no problems.
This is implemented to conform to how bayonetta is checking async read/write operations.
https://bugs.winehq.org/show_bug.cgi?id=42982
--- Comment #7 from Toni eldrad@autistici.org --- I have investigated this error and found out these are the relevant error lines:
0009:Call KERNEL32.CreateFileA(0033fb48 "C:\users\user\My Documents/Bayonetta/system_data",80000000,00000000,00000000,00000003,40000080,00000000) ret=00c7dff4 0009:Ret KERNEL32.CreateFileA() retval=00000190 ret=00c7dff4 (...) 0009:Call KERNEL32.ReadFile(00000190,066c9e60,00000690,00000000,05ba3544) ret=00c7e040 0009:Ret KERNEL32.ReadFile() retval=00000001 ret=00c7e040 0009:Call KERNEL32.GetLastError() ret=00c7e046 0009:Ret KERNEL32.GetLastError() retval=00000000 ret=00c7e046 (...) 0009:Call msvcr100.vswprintf_s(05b85690,00000200,00e712bc L"Failed to read save data.",0033fc50) ret=00c71c9e
Turns out the program is launching an asynchronous operation on file read, and badly checking error conditions, it seems to only accept the operation as correct if it sees LastError set to STATUS_PENDING. The root error is because wine doesn't respect the async command and just performs all file/reads in sync manner.
Attached two alternative patches fixing the issue for bayonetta. The first one just sets the error to STATUS_PENDING even if the operation is done synchronous, this seems to allow the application to continue and indeed read/write the files. The second alternative actually runs the read/writes asynchronously through wineserver.
https://bugs.winehq.org/show_bug.cgi?id=42982
--- Comment #8 from Toni eldrad@autistici.org --- In my last comment I have pasted the error lines relative to read operation affecting related bug: https://bugs.winehq.org/show_bug.cgi?id=43071
For this bug the error lines are very similar but doing WriteFile instead of ReadFile, in the end both bugs are affected by the same behaviour from read/write operations. Bayonetta does GetLastError, it sees there is no STATUS_PENDING error and assumes the operation failed.
https://bugs.winehq.org/show_bug.cgi?id=42982
Toni eldrad@autistici.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #58627|0 |1 is obsolete| |
--- Comment #9 from Toni eldrad@autistici.org --- Created attachment 58628 --> https://bugs.winehq.org/attachment.cgi?id=58628 Alternative2: Do read/write really asynchronous v2
Alternative2 path making asynchronous read/write requests perform asynchronously. This is v2 fixing some compiler warnings and indentation.
https://bugs.winehq.org/show_bug.cgi?id=42982
--- Comment #10 from Zentarim zentarim@rambler.ru --- Patch https://bugs.winehq.org/attachment.cgi?id=58628&action=diff is helped! Many thanks!
https://bugs.winehq.org/show_bug.cgi?id=42982
--- Comment #11 from Zentarim zentarim@rambler.ru --- (In reply to Zentarim from comment #10)
Patch https://bugs.winehq.org/attachment.cgi?id=58628&action=diff is helped! Many thanks!
Used Wine version: wine-2.11-190-g4e2c044
https://bugs.winehq.org/show_bug.cgi?id=42982
Toni eldrad@autistici.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #58628|0 |1 is obsolete| |
--- Comment #12 from Toni eldrad@autistici.org --- Created attachment 58637 --> https://bugs.winehq.org/attachment.cgi?id=58637 Alternative2: Do read/write really asynchronous v3
v3: Respect offset for read/write operations.
This doesn't affect bayonetta but it can impact other applications. If you have applied the previous patch you should update to this one (specially if testing with other applications).
Make sure to backup your wineprefix when testing the "alternative 2" patch because programming error could lead to data loss (should be safe for bayonetta though).
Patch made from wine 2.11 git 6ec3cd9434488ba5bc0fd271a47b7d46827477c5
https://bugs.winehq.org/show_bug.cgi?id=42982
--- Comment #13 from Zentarim zentarim@rambler.ru --- (In reply to Toni from comment #12)
Created attachment 58637 [details] Alternative2: Do read/write really asynchronous v3
v3: Respect offset for read/write operations.
This doesn't affect bayonetta but it can impact other applications. If you have applied the previous patch you should update to this one (specially if testing with other applications).
Make sure to backup your wineprefix when testing the "alternative 2" patch because programming error could lead to data loss (should be safe for bayonetta though).
Patch made from wine 2.11 git 6ec3cd9434488ba5bc0fd271a47b7d46827477c5
This patch also working. I used patched version to run bayonetta and microsoft excel\visio\word 2007 ( load\modify\save files). In both cases without problems. Wine version 2.12 commit a94938819280aa52fbc545911ca70a6c3a83ab49
Toni, thanks a lot!
https://bugs.winehq.org/show_bug.cgi?id=42982
mrdeathjr28@yahoo.es changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |mrdeathjr28@yahoo.es
https://bugs.winehq.org/show_bug.cgi?id=42982
--- Comment #14 from Zentarim zentarim@rambler.ru --- it's possible to hope, this patch will be merged in master branch?
https://bugs.winehq.org/show_bug.cgi?id=42982
--- Comment #15 from Toni eldrad@autistici.org --- (In reply to Zentarim from comment #14)
it's possible to hope, this patch will be merged in master branch?
I don't think we have much hope of merging this, even on staging, we will need to debug more to find out more information about why the application fails, maybe by running tests (simple tests checking behaviour on windows might be enough) on windows or debugging the internal calls more with a debugger.
The issue is windows is expected to behave like this (async operations can return synchronously), so it's not entirely justifiable, even if I thought it might be beneficial to perform asynchronously when requested, we also don't have specific cases about where this could improve performance. Also adapting the unit tests is quite hairy, that would also be a necessary first step but I'm not putting much hopes on that path to lead us anywhere soon.
So my bets are the moment are in finding out something more subtle that's actually causing the problem (In how read/write are being called and how the overlapped structure is being managed).
Otherwise I'm thinking of providing a version of koku-xinput-wine with a hotpatch for alternative1, that would be a reasonable albeit non standard fix for the moment, since koku-xinput also allows controllers to work fine with bayonetta (it's the only way i've managed to get rumble working on the gamepad).
Another way that might be possible to get accepted in staging is having the async behaviour as an optional feature enabled via registry, but the fact only bayonetta seems to be affected makes it tricky to make other devs willing to hear about the issue (they say we should debug more to find a root cause).
So this are our options:
- Find out a more subtle root cause that can actually be fixed (might get us into wine) - Push async behaviour forward by providing unit tests and making it optional behaviour (might get us into staging) - Hotpatch through ld_preload (would work as something people can use without compiling themselves or requiring a full alternative version of wine just to support bayonetta)
Also it would be beneficial to us finding other applications making use of the async behaviour in read and write.
https://bugs.winehq.org/show_bug.cgi?id=42982
Turo Lamminen turotl@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |turotl@gmail.com
https://bugs.winehq.org/show_bug.cgi?id=42982
Matteo Bruni matteo.mystral@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Blocks| |44129
https://bugs.winehq.org/show_bug.cgi?id=42982
Mikko Niemelä mikko.niemela@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |mikko.niemela@gmail.com
--- Comment #16 from Mikko Niemelä mikko.niemela@gmail.com --- (In reply to Toni from comment #15)
Also it would be beneficial to us finding other applications making use of the async behaviour in read and write.
Vanquish by Platinum Games has this same problem of not being able to save settings.
https://bugs.winehq.org/show_bug.cgi?id=42982
--- Comment #17 from Toni eldrad@autistici.org --- The patch also worksaround the problem in Vanquish.
https://bugs.winehq.org/show_bug.cgi?id=42982
Chebanenko Igor chebanenkoigor93@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |chebanenkoigor93@gmail.com
--- Comment #18 from Chebanenko Igor chebanenkoigor93@gmail.com --- (In reply to Mikko Niemelä from comment #16)
(In reply to Toni from comment #15)
Also it would be beneficial to us finding other applications making use of the async behaviour in read and write.
Vanquish by Platinum Games has this same problem of not being able to save settings.
Try this 3 commits,merge all commits, looks like it will help:
1) https://source.winehq.org/git/wine.git/commit/7ce2a8e0ae3d107f7dbeeeebb4b118...
2) https://source.winehq.org/git/wine.git/commit/9dc63ca9813b9aec1384160afb19a8...
3) https://source.winehq.org/git/wine.git/commit/3117370acceeb2606d0f6dde420a73...
It was for bug with Second Sight game (https://bugs.winehq.org/show_bug.cgi?id=31954),but try it.
https://bugs.winehq.org/show_bug.cgi?id=42982
Paul Gofman gofmanp@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |gofmanp@gmail.com
--- Comment #19 from Paul Gofman gofmanp@gmail.com --- Created attachment 63648 --> https://bugs.winehq.org/attachment.cgi?id=63648 Report async read / write
(In reply to Chebanenko Igor from comment #18)
(In reply to Mikko Niemelä from comment #16)
(In reply to Toni from comment #15)
Also it would be beneficial to us finding other applications making use of the async behaviour in read and write.
Vanquish by Platinum Games has this same problem of not being able to save settings.
Try this 3 commits,merge all commits, looks like it will help:
Those won't help here, from what I see in logs Bayonetta does not set FILE_FLAG_NO_BUFFERING on file open.
If anyone can test with the patch series attached that would be great.
https://bugs.winehq.org/show_bug.cgi?id=42982
--- Comment #20 from mrdeathjr28@yahoo.es --- Hi and thanks for your patch
I can test but until julliard approve patch
https://bugs.winehq.org/show_bug.cgi?id=42982
--- Comment #21 from Chebanenko Igor chebanenkoigor93@gmail.com --- (In reply to mrdeathjr28 from comment #20)
Hi and thanks for your patch
I can test but until julliard approve patch
Test your game in Wine 4.3
https://bugs.winehq.org/show_bug.cgi?id=42982
--- Comment #22 from mrdeathjr28@yahoo.es --- (In reply to Chebanenko Igor from comment #21)
(In reply to mrdeathjr28 from comment #20)
Hi and thanks for your patch
I can test but until julliard approve patch
Test your game in Wine 4.3
Sadly two keystones patchs dont stay:
https://source.winehq.org/patches/data/158920
https://source.winehq.org/patches/data/158921
This is discussion between paul gofman and jacek kaban respect this patch:
On 2/26/19 7:45 PM, Paul Gofman wrote:
Hello Jacek,
On 2/26/19 17:23, Jacek Caban wrote:
While it generally looks like Vista+ indeed returns STATUS_PENDING in quite a lot of situations, doing it always in all cases is probably not the right thing. For example, read()/write() on overlapped named pipes does not return STATUS_PENDING if the request may be completed immediately. Although named pipe read/write use different code path in Wine, the general concern remains: we can't assume that Windows does that unconditionally for all all overlapped requests.
Do you think this can be considered for regular files?
I don't know, is STATUS_PENDING specific to regular files?
Ignoring fd type in my patch is definitely a mistake. The motivation under this are applications which now sometimes strictly expect async status when reading / writing regular files asynchronously (they are not XP compatible of course). Is it absolutely no go to make this behaviour dependant on defined win version?
If it can be avoided, yes. I think we should carefully change it to STATUS_PENDING because we have an evidence that some applications need it. We don't know if anything will break.
Also note that such change may need throughout review of Wine to make sure that we don't depend on pre-Vista behaviour in our code. read()/write() should be safer, but I've seen STATUS_PENDING returned from ioctl()s as well (even on pipes), and changing that would surely break kernel32 code.
I can search for it. Hopefully this is not so common case to request an overlapped file IO and then always expect sync results.
More like a code that calls ReadFile on a handle passed from an application that happens to be overlapped. Or overlapped file handle is created by accident, since with current code it doesn't matter for file handles. Anyway, it doesn't seem likely.
Jacek
https://bugs.winehq.org/show_bug.cgi?id=42982
--- Comment #23 from mrdeathjr28@yahoo.es --- Fixed in last git
Many Thanks Paul Gofman - Jacek Kaban
https://bugs.winehq.org/show_bug.cgi?id=42982
--- Comment #24 from mrdeathjr28@yahoo.es --- Vanquish fixed too many thanks
https://bugs.winehq.org/show_bug.cgi?id=42982
Matteo Bruni matteo.mystral@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |56f34c7489cb463981e987a59ae | |e9f8780fef7cd Status|UNCONFIRMED |RESOLVED Resolution|--- |FIXED
--- Comment #25 from Matteo Bruni matteo.mystral@gmail.com --- Reported fixed, https://source.winehq.org/git/wine.git/commitdiff/56f34c7489cb463981e987a59a...
https://bugs.winehq.org/show_bug.cgi?id=42982
Matteo Bruni matteo.mystral@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Summary|Bayonetta can`t save |Bayonetta can't save |settings |settings
https://bugs.winehq.org/show_bug.cgi?id=42982
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #26 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 4.4.