QML: do not check stack size if stack grows up
authorRolf Eike Beer <eb@emlix.com>
Wed, 4 Feb 2015 12:24:53 +0000 (13:24 +0100)
committerSimon Hausmann <simon.hausmann@theqtcompany.com>
Tue, 21 Apr 2015 08:52:06 +0000 (08:52 +0000)
On architectures where the stack grows upwards (i.e. HP PA-RISC) the
stack limit calculation fails because the variables used to check the
offset are usually close to the bottom of the stack, which is in this
case the origin of the stack grows. Since these machines are a rare
obscurity simply assume that everything is fine on these machines. The
few people that are indeed running QML on such machines will probably
be able configure their stack size properly by default.

Task-number: QTBUG-44268
Change-Id: Ia83a39179a0f6e0602ba7a5032d386e12d8d1ba3
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
src/qml/jsruntime/qv4engine.cpp

index 5bba745..6156e5c 100644 (file)
@@ -108,8 +108,14 @@ quintptr getStackLimit()
     } else
         size = pthread_get_stacksize_np(thread_self);
     stackLimit -= size;
+#  elif defined(__hppa)
+    // On some architectures the stack grows upwards. All of these are rather exotic, so simply assume
+    // everything is fine there.
+    // Known examples:
+    // -HP PA-RISC
+    stackLimit = 0;
+
 #  else
-    void* stackBottom = 0;
     pthread_attr_t attr;
 #if HAVE(PTHREAD_NP_H) && OS(FREEBSD)
     // on FreeBSD pthread_attr_init() must be called otherwise getting the attrs crashes
@@ -117,7 +123,9 @@ quintptr getStackLimit()
 #else
     if (pthread_getattr_np(pthread_self(), &attr) == 0) {
 #endif
+        void *stackBottom = Q_NULLPTR;
         size_t stackSize = 0;
+
         pthread_attr_getstack(&attr, &stackBottom, &stackSize);
         pthread_attr_destroy(&attr);