https://bugs.winehq.org/show_bug.cgi?id=50704
Bug ID: 50704 Summary: QueueUserAPC() Has Incorrect Error Set When Called On Terminating Thread Product: Wine Version: 6.2 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: ntdll Assignee: wine-bugs@winehq.org Reporter: spambox1@koolhoven-home.net Distribution: ---
DWORD QueueUserAPC() will return zero with GetLastError() set to return ERROR_ACCESS_DENIED if called on a terminating thread, but ERROR_GEN_FAILURE is the expected return of GetLastError() in this scenario.
Unfortunately, it's hard to catch a thread in this state since once a thread has been terminated completely calling on it results in GetLastError() returning ERROR_INVALID_HANDLE as it should.
This effects applications using older versions of WebRTC, such as StarCitizen. The chromium development team noticed this and built a workaround into WebRTC to make WebRTC compatible with WINE and Windows in this commit: https://webrtc.googlesource.com/src/+/dbfb58b850c14eeadac5ac66689fb855c79abf36%5E%21/, but the underlying issue still persists in WINE.
https://bugs.winehq.org/show_bug.cgi?id=50704
David Koolhoven spambox1@koolhoven-home.net changed:
What |Removed |Added ---------------------------------------------------------------------------- URL| |https://webrtc.googlesource | |.com/src/+/dbfb58b850c14eea | |dac5ac66689fb855c79abf36%5E | |%21/ Distribution|--- |ArchLinux Regression SHA1| |442f5f56d1c3367c9d166ef340a | |682a390bd57cb
https://bugs.winehq.org/show_bug.cgi?id=50704
--- Comment #1 from David Koolhoven spambox1@koolhoven-home.net --- This causes StarCitizen's VoIP (and possibly FoIP) to fail with a runtime error usually within 20 minutes of gameplay, and is associated with leaving and joining channels which the program makes called to WebRTC to accomplish.
https://bugs.winehq.org/show_bug.cgi?id=50704
--- Comment #2 from David Koolhoven spambox1@koolhoven-home.net --- A patch changing this correct the Runtime Error and subsequent VoIP failure.
https://bugs.winehq.org/show_bug.cgi?id=50704
rawfox rawfox@freenet.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |rawfox@freenet.de
--- Comment #3 from rawfox rawfox@freenet.de --- Amazing :O With patch, superb. Testing this, ill report back here. Thank you !
https://bugs.winehq.org/show_bug.cgi?id=50704
David Koolhoven spambox1@koolhoven-home.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Regression SHA1|442f5f56d1c3367c9d166ef340a |6ca1d1b0812496e670957543294 |682a390bd57cb |b04abfefe8d78
--- Comment #4 from David Koolhoven spambox1@koolhoven-home.net --- A commit has been submitted that changes code from this other commit: 6ca1d1b0812496e670957543294b04abfefe8d78
I'm recording here the original regression tag which was not changed in today's commit: 442f5f56d1c3367c9d166ef340a682a390bd57cb
And here is the changing commit: 050dc49b3850a9cf807d995c2c8e8c3f244b9f11
https://bugs.winehq.org/show_bug.cgi?id=50704
David Koolhoven spambox1@koolhoven-home.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|UNCONFIRMED |RESOLVED
--- Comment #5 from David Koolhoven spambox1@koolhoven-home.net --- I've tested for about an hour and I cannot reproduce this problem with the following commit: https://source.winehq.org/git/wine.git/commit/050dc49b3850a9cf807d995c2c8e8c...
Nice work!
https://bugs.winehq.org/show_bug.cgi?id=50704
David Koolhoven spambox1@koolhoven-home.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |regression
https://bugs.winehq.org/show_bug.cgi?id=50704
Dmitry Timoshkov dmitry@baikal.ru changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |050dc49b3850a9cf807d995c2c8 | |e8c3f244b9f11
https://bugs.winehq.org/show_bug.cgi?id=50704
David Koolhoven spambox1@koolhoven-home.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Version|6.2 |6.3
--- Comment #6 from David Koolhoven spambox1@koolhoven-home.net --- I'm updating the bug record to 6.3 since it existed in release 6.3, but is resolved at the git committed.
https://bugs.winehq.org/show_bug.cgi?id=50704
Gijs Vermeulen gijsvrm@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Version|6.3 |6.2
--- Comment #7 from Gijs Vermeulen gijsvrm@gmail.com --- (In reply to David Koolhoven from comment #6)
I'm updating the bug record to 6.3 since it existed in release 6.3, but is resolved at the git committed.
The version field is supposed to represent the earliest reported version that the bug appeared in. So I'll change it back to 6.2, but thanks for all the effort anyway!
https://bugs.winehq.org/show_bug.cgi?id=50704
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #8 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 6.4.
https://bugs.winehq.org/show_bug.cgi?id=50704
Michael Stefaniuc mstefani@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |6.0.x
https://bugs.winehq.org/show_bug.cgi?id=50704
Michael Stefaniuc mstefani@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|6.0.x |---
--- Comment #9 from Michael Stefaniuc mstefani@winehq.org --- Removing the 6.0.x milestone from bug fixes included in 6.0.1.
https://bugs.winehq.org/show_bug.cgi?id=50704
Mehmet gelisin mehmetgelisin@aol.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |mehmetgelisin@aol.com
--- Comment #10 from Mehmet gelisin mehmetgelisin@aol.com --- I just found this in the cryptopp readme:
``` *** DLL Memory Management *** http://www.compilatori.com/
Because it's possible for the Crypto++ DLL to delete objects allocated by the calling application, they must use the same C++ memory heap. Three methods are provided to achieve this. http://www.wearelondonmade.com/ 1. The calling application can tell Crypto++ what heap to use. This method is required when the calling application uses a non-standard heap. http://www.jopspeech.com/ 2. Crypto++ can tell the calling application what heap to use. This method is required when the calling application uses a statically linked C++ Run Time Library. (Method 1 does not work in this case because the Crypto++ DLL is initialized before the calling application's heap is initialized.) http://joerg.li/ 3. Crypto++ can automatically use the heap provided by the calling application's http://connstr.net/ dynamically linked C++ Run Time Library. The calling application must make sure that the dynamically linked C++ Run Time Library is initialized before Crypto++ is loaded. http://embermanchester.uk/ (At this time it is not clear if it is possible to control the order in which DLLs are initialized on Windows 9x machines, so it might be best to avoid using this method.) http://www.slipstone.co.uk/
When Crypto++ attaches to a new process, it searches all modules loaded into the process space for exported functions "GetNewAndDeleteForCryptoPP" and "SetNewAndDeleteFromCryptoPP". If one of these functions is found, http://www.logoarts.co.uk/ Crypto++ uses methods 1 or 2, respectively, by calling the function. Otherwise, method 3 is used. ``` http://www.acpirateradio.co.uk/ I'm guessing we're hitting case 3, and cryptopp doesn't bother to look for ucrt?
I just found this in the cryptopp readme:
``` *** DLL Memory Management *** https://waytowhatsnext.com/
Because it's possible for the Crypto++ DLL to delete objects allocated by the calling application, they must use the same C++ memory heap. Three methods are provided to achieve this. https://www.webb-dev.co.uk/ 1. The calling application can tell Crypto++ what heap to use. This method is required when the calling application uses a non-standard heap. 2. Crypto++ can tell the calling application what heap to use. This method is required when the calling application uses a statically linked C++ Run Time Library. (Method 1 does not work in this case because the Crypto++ DLL is initialized before the calling application's heap is initialized.) 3. Crypto++ can automatically use the heap provided by the calling application's http://www.iu-bloomington.com/ dynamically linked C++ Run Time Library. The calling application must make sure that the dynamically linked C++ Run Time Library is initialized before Crypto++ is loaded. (At this time it is not clear if it is possible to control the order in which DLLs are initialized on Windows 9x machines, so it might be best to avoid using this method.)
When Crypto++ attaches to a new process, it searches all modules loaded http://www-look-4.com/ into the process space for exported functions "GetNewAndDeleteForCryptoPP" and "SetNewAndDeleteFromCryptoPP". If one of these functions is found, Crypto++ uses methods 1 or 2, respectively, by calling the function. Otherwise, method 3 is used. ```
I'm guessing we're hitting case 3, and cryptopp doesn't bother to look for ucrt?
I just found this in the cryptopp readme:
``` *** DLL Memory Management ***
Because it's possible for the Crypto++ DLL to delete objects allocated by the calling application, they must use the same C++ memory heap. Three methods are provided to achieve this. 1. The calling application can tell Crypto++ what heap to use. This method is required when the calling application uses a non-standard heap. 2. Crypto++ can tell the calling application what heap to use. This method is required when the calling application uses a statically linked C++ Run Time Library. (Method 1 does not work in this case because the Crypto++ DLL is initialized before the calling application's heap is initialized.) 3. Crypto++ can automatically use the heap provided by the calling application's dynamically linked C++ Run Time Library. The calling application must make sure that the dynamically linked C++ Run Time Library is initialized before Crypto++ is loaded. (At this time it is not clear if it is possible to control the order in which DLLs are initialized on Windows 9x machines, so it might be best to avoid using this method.)
When Crypto++ attaches to a new process, it searches all modules loaded into the process space for exported functions "GetNewAndDeleteForCryptoPP" and "SetNewAndDeleteFromCryptoPP". If one of these functions is found, Crypto++ uses methods 1 or 2, respectively, by calling the function. Otherwise, method 3 is used. ```
I'm guessing we're hitting case 3, and cryptopp doesn't bother to look for ucrt?