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

QLockFile stale lock file removal detection fails if non-ASCII characters in host name

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • P4: Low
    • None
    • 5.5.1
    • Core: I/O
    • None

    Description

      The stale lock file detection fails on Windows if the computer name contains non-ASCII characters, for example German Umlaute.

      Scenario: my program uses a QLockFile for detecting if another instance is already running. If my program crashes and the user restarts it then my program relies on QLockFile to detect a stale lock file.

      This works nicely in most cases, but not on Windows if and only if the computer name contains non-ASCII characters. If the computer name is purely ASCII (e.g. "TEST123") then QLockFile detects the lock as stale, removes it, and the program continues running.

      If, however, the computer name is e.g. "TÄST123" then QLockFile won't detect the file as being stale even though the third line in the file contains "TÄST123".

      The reason is that different encodings are used when writing the host name and when reading it. The reading code in qlockfile.cpp:getLockInfo() assumes that UTF-8 is used. However, the code creating the lock file in qlockfile_win.cpp:tryLock_sys() writes out the QByteArray returned by qgetenv() verbatim, and that QByteArray uses Window's local encoding and not UTF-8.

      The solution should be to convert the host name from the local encoding to UTF-8 before writing it to the lock file.

      Attachments

        For Gerrit Dashboard: QTBUG-49640
        # Subject Branch Project Status CR V

        Activity

          People

            dfaure_kdab David Faure
            mbunkus Moritz Bunkus
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews