Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
6.0.2, 6.1.0 Beta3
-
None
-
Windows x64, Visual Studio 2019
Description
QSemaphore tryAcquire throws an "access denied" fault in QWaitConditionPrivate::wait, in the Windows function WaitForSingleObjectEx.
bool QWaitConditionPrivate::wait(QWaitConditionEvent *wce, unsigned long time) { // wait for the event bool ret = false; switch (WaitForSingleObjectEx(wce->event, time, FALSE)) { default: break; case WAIT_OBJECT_0: ret = true; break; } return ret; }
It appears that the handle event does not have SYNCHRONIZE access rights.
https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitforsingleobjectex
"The handle must have the SYNCHRONIZE access right. For more information, see Standard Access Rights."
STANDARD_RIGHTS_ALL may be used also.
event is created here:
inline QWaitConditionEvent() : priority(0), wokenUp(false)
{
event = CreateEvent(NULL, TRUE, FALSE, NULL);
}
https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-createeventa
I believe event should be created with CreateEventEx.
HANDLE CreateEventExA( LPSECURITY_ATTRIBUTES lpEventAttributes, LPCSTR lpName, DWORD dwFlags, DWORD dwDesiredAccess );
to add SYNCHRONIZE in the dwDesiredAccess parameter.
https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-createeventexa
I can provide a Visual Studio project that demonstrates the issue , if needed.