Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

qt4/5: default thread stack size is too small on OS X, set it to a reasonable value #46307

Closed
devernay opened this issue Nov 24, 2015 · 2 comments

Comments

@devernay
Copy link

(bug submitted upstream, https://bugreports.qt.io/browse/QTBUG-49607)

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)

patch file: https://bugreports.qt.io/secure/attachment/52514/patch-qthread-stacksize.diff

@MikeMcQuaid
Copy link
Member

We'd consider accepting this patch after Qt has done so. I'd personally recommend submitting this to their Gerrit rather than Jira (as they actually look at their Gerrit).

@devernay
Copy link
Author

thanks.

In the mean time, the following addition to the recipe works.
Execute brew edit qt4 and add this before the line that starts with head:

  patch :p0 do
    url "https://bugreports.qt.io/secure/attachment/52520/patch-qthread-stacksize.diff"
    sha256 "477630235eb5ee34ed04e33f156625d1724da290e7a66b745611fb49d17f1347"
  end

Then, install qt with

brew install --build-from-source qt

@Homebrew Homebrew locked and limited conversation to collaborators Jul 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants