diff options
author | aavit <eirik.aavitsland@digia.com> | 2013-12-17 16:11:19 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-17 21:36:34 +0100 |
commit | 0697a941321ed6688fd2cb7bd60028c56e0e19b6 (patch) | |
tree | fd9792595b9410f64d4bb53acd32c708f2f86e48 /src/qml | |
parent | 2d4719876df240edc740e15f193cec5ff9c55203 (diff) |
Fixes: qml memory corruption on Android
Bionic pthreads reports too small stack size for main thread.
Change-Id: I3d33229e76101a847309c723d534844ffb2d2042
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index dc8c0da321..539bc5ddd6 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -76,6 +76,7 @@ #if USE(PTHREADS) # include <pthread.h> +# include <sys/resource.h> #endif QT_BEGIN_NAMESPACE @@ -113,6 +114,15 @@ quintptr getStackLimit() pthread_attr_getstack(&attr, &stackBottom, &stackSize); pthread_attr_destroy(&attr); +# if defined(Q_OS_ANDROID) + // Bionic pretends that the main thread has a tiny stack; work around it + if (gettid() == getpid()) { + rlimit limit; + getrlimit(RLIMIT_STACK, &limit); + stackBottom = reinterpret_cast<void*>(reinterpret_cast<quintptr>(stackBottom) + stackSize - limit.rlim_cur); + } +# endif + stackLimit = reinterpret_cast<quintptr>(stackBottom); # endif // This is wrong. StackLimit is the currently committed stack size, not the real end. |