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

Default stack size for QThread on OSX is unreasonably small. Replicate linux's behaviour instead.

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Duplicate
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 4.8.7, 5.5.1
    • Core: Threads
    • None
    • all versions of Mac OS X

    • macOS

      OS X provides no way to set the default stack size for threads (it is always 512k), whereas the main thread stack size (default is 8M) can be set by setrlimit().

      QThreadPool provides no way to change the stack size from the default https://bugreports.qt.io/browse/QTBUG-2568.

      This, and the fact that clang does not optimize stack usage as well as gcc does, may cause stack overflow in programs that would run very well on linux or windows. Computation-intensive applications are affected by this problem.

      This patch does the same fix as in Chromium ​https://chromium.googlesource.com/chromium/src.git/+/master/base/threading/platform_thread_mac.mm#186, and gives the same behaviour as on Linux:

      If the thread stack size is not set explicitely, it is set to at least the same value as the main thread.

      patch is for Qt 4.8.7, but very easy to adapt for Qt 5.5.1 (apply to qtbase/src/corelib/thread/qthread_unix.cpp)

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

            Unassigned Unassigned
            devernay Frederic Devernay
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes