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

qErrnoWarning(int errno, ...) reports incorrect error messages on Windows

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4: Low P4: Low
    • Some future release
    • 4.5.2, 4.6.1, 5.7.0
    • Other
    • None
    • Windows XP, Visual Studio 2005

      qErrnoWarning(int code, const char* msg, ...) calls qt_error_string(), which uses the FormatMessage() function under Windows. Unfortunately, this API is not meant for errno values, but for error codes returned by GetLastError(). These are not compatible at all.

      This can lead to confusing errors from Qt, such as the following (from a real-life situation) :

      [Qt Critical] QThread::start: Failed to create thread (The access code is invalid.)

      This should have been :

      [Qt Critical] QThread::start: Failed to create thread (Not enough space.)

      That's because error code 12 means ENOMEM for errno, while it means ERROR_INVALID_ACCESS for GetLastError(). In other words, qErrnoWarning(ENOMEM, "...") prints "The acces code is invalid", instead of "Not enough space".

      qErrnoWarning should use strerror(), and qt_error_string() shouldn't be used with errno values, only with GetLastError() values.

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

            macadder Jason McDonald
            jcugniere Julien Cugnière
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes