Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-92823

QSemaphore throws "Access Denied" exception

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 6.0.2, 6.1.0 Beta3
    • Core: Threads
    • None
    • Windows x64, Visual Studio 2019
    • Windows

    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

       

      https://docs.microsoft.com/en-us/windows/win32/sync/synchronization-object-security-and-access-rights

       I can provide a Visual Studio project that demonstrates the issue , if needed.

       

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            doug_rogers Doug Rogers
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes