[rkward-cvs] SF.net SVN: rkward: [2152] trunk/rkward/rkward/rbackend

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue Oct 30 16:40:56 UTC 2007


Revision: 2152
          http://rkward.svn.sourceforge.net/rkward/?rev=2152&view=rev
Author:   tfry
Date:     2007-10-30 09:40:56 -0700 (Tue, 30 Oct 2007)

Log Message:
-----------
Experimental: Try to make stack checking limit detection more reliable

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

Modified: trunk/rkward/rkward/rbackend/rkpthreadsupport.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkpthreadsupport.cpp	2007-10-30 16:11:06 UTC (rev 2151)
+++ trunk/rkward/rkward/rbackend/rkpthreadsupport.cpp	2007-10-30 16:40:56 UTC (rev 2152)
@@ -29,8 +29,7 @@
 
 /* Much of this code is borrowed from WINE (http://www.winehq.org) */
 
-void RKGetCurrentThreadStackLimits (size_t *size, void **base) {
-	char dummy;
+void RKGetCurrentThreadStackLimits (size_t *size, void **base, char *reference) {
 	int direction;
 #ifdef HAVE_PTHREAD_GETATTR_NP
 	pthread_attr_t attr;
@@ -49,18 +48,18 @@
 #else
 #	warning Cannot determine the stack limits of a pthread on this system
 #	warning R C stack checking will be disabled
-	*base = &dummy;
+	*base = reference;
 	*size = (unsigned long) -1;
 	return;
 #endif
 	// in which direction does the stack grow?
 	{
 		char dummy2;
-		direction = (&dummy) > (&dummy2) ? 1 : -1;
+		direction = reference > (&dummy2) ? 1 : -1;
 	}
 
 	// in which direction does the stack base lie?
-	int base_direction = (*base) > (&dummy) ? 1 : -1;
+	int base_direction = (*base) > reference ? 1 : -1;
 
 	// switch base / top, if necessary
 	if (base_direction != direction) {
@@ -68,7 +67,7 @@
 	}
 
 	// sanity check, as on some systems the stack direction is mis-detected somehow.
-	long usage = direction * ((unsigned long) (*base) - (unsigned long) (&dummy));
+	long usage = direction * ((unsigned long) (*base) - (unsigned long) (reference));
 	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;

Modified: trunk/rkward/rkward/rbackend/rkpthreadsupport.h
===================================================================
--- trunk/rkward/rkward/rbackend/rkpthreadsupport.h	2007-10-30 16:11:06 UTC (rev 2151)
+++ trunk/rkward/rkward/rbackend/rkpthreadsupport.h	2007-10-30 16:40:56 UTC (rev 2152)
@@ -21,6 +21,6 @@
 #include <stddef.h>
 
 /** Try different ways to get the stack limits of the currently running thread */
-void RKGetCurrentThreadStackLimits (size_t *size, void **base);
+void RKGetCurrentThreadStackLimits (size_t *size, void **base, char *reference);
 
 #endif

Modified: trunk/rkward/rkward/rbackend/rthread.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rthread.cpp	2007-10-30 16:11:06 UTC (rev 2151)
+++ trunk/rkward/rkward/rbackend/rthread.cpp	2007-10-30 16:40:56 UTC (rev 2152)
@@ -472,7 +472,8 @@
 		stacksize = (unsigned long) -1;
 		stackstart = (void *) -1;
 	} else {
-		RKGetCurrentThreadStackLimits (&stacksize, &stackstart);
+		char dummy;
+		RKGetCurrentThreadStackLimits (&stacksize, &stackstart, &dummy);
 	}
 	startR (argc, argv, stacksize, stackstart);
 


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