[rkward-cvs] SF.net SVN: rkward: [1865] trunk/rkward/rkward/rbackend/rkpthreadsupport. cpp

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon May 7 10:50:46 UTC 2007


Revision: 1865
          http://svn.sourceforge.net/rkward/?rev=1865&view=rev
Author:   tfry
Date:     2007-05-07 03:50:45 -0700 (Mon, 07 May 2007)

Log Message:
-----------
Add sanity check for stack detection

Modified Paths:
--------------
    trunk/rkward/rkward/rbackend/rkpthreadsupport.cpp

Modified: trunk/rkward/rkward/rbackend/rkpthreadsupport.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkpthreadsupport.cpp	2007-05-07 10:31:56 UTC (rev 1864)
+++ trunk/rkward/rkward/rbackend/rkpthreadsupport.cpp	2007-05-07 10:50:45 UTC (rev 1865)
@@ -19,6 +19,9 @@
 
 #include "../../config.h"
 
+#include <qstring.h>
+#include "../debug.h"
+
 #include <pthread.h>
 #ifdef HAVE_PTHREAD_NP_H
 #	include <pthread_np.h>
@@ -63,4 +66,11 @@
 	if (base_direction != direction) {
 		*base = ((char *) *base) + (direction * ((unsigned long) *size));
 	}
+
+	// sanity check, as on some systems the stack direction is mis-detected somehow.
+	long usage = direction * ((unsigned long) (*base) - (unsigned long) (&dummy));
+	if ((usage < 0) || (unsigned long) usage > (unsigned long) (*size)) {
+		RK_DO (qDebug ("Stack boundaries detection produced bad results. Disabling stack checking."), RBACKEND, DL_WARNING);
+		*size = (unsigned long) -1;
+	}
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list