[rkward-cvs] SF.net SVN: rkward: [2266] branches/KDE4_port

tfry at users.sourceforge.net tfry at users.sourceforge.net
Thu Nov 22 14:49:01 UTC 2007


Revision: 2266
          http://rkward.svn.sourceforge.net/rkward/?rev=2266&view=rev
Author:   tfry
Date:     2007-11-22 06:49:00 -0800 (Thu, 22 Nov 2007)

Log Message:
-----------
Let R only handle SIGSEGV, if it is the active thread

Modified Paths:
--------------
    branches/KDE4_port/ChangeLog
    branches/KDE4_port/rkward/rbackend/rinterface.cpp
    branches/KDE4_port/rkward/rbackend/rinterface.h

Modified: branches/KDE4_port/ChangeLog
===================================================================
--- branches/KDE4_port/ChangeLog	2007-11-22 14:01:55 UTC (rev 2265)
+++ branches/KDE4_port/ChangeLog	2007-11-22 14:49:00 UTC (rev 2266)
@@ -1,3 +1,4 @@
+- make sure that R only handles SIGSEV, when the R thread is active. Should give better backtraces and less hangs
 - object viewer was redesigned to use space better, and only fetch the print-representation when needed
 - more icons added
 - data.frame editor can be set to read-only mode

Modified: branches/KDE4_port/rkward/rbackend/rinterface.cpp
===================================================================
--- branches/KDE4_port/rkward/rbackend/rinterface.cpp	2007-11-22 14:01:55 UTC (rev 2265)
+++ branches/KDE4_port/rkward/rbackend/rinterface.cpp	2007-11-22 14:49:00 UTC (rev 2266)
@@ -52,7 +52,36 @@
 #include <qvalidator.h>
 
 #include <stdlib.h>
+#include <signal.h>
 
+#ifndef __sighandler_t
+typedef void (*__sighandler_t) (int);
+#endif
+__sighandler_t r_sigsegv_handler = 0;
+__sighandler_t default_sigsegv_handler = 0;
+
+void sigsegv_proxy (int signum) {
+	RK_ASSERT (signum == SIGSEGV);
+
+	// if we are not in the R thread, handling the signal in R does more harm than good.
+	if (RInterface::inRThread ()) {
+		if (r_sigsegv_handler) {
+			r_sigsegv_handler (signum);
+			return;
+		}
+	}
+
+	// this might be a Qt/KDE override
+	if (default_sigsegv_handler) {
+		default_sigsegv_handler (signum);
+		return;
+	}
+
+	signal(SIGSEGV,SIG_DFL);
+	raise(SIGSEGV);
+}
+
+
 // update output (for immediate output commands) at least this often (msecs):
 #define FLUSH_INTERVAL 100
 
@@ -134,6 +163,8 @@
 
 void RInterface::startThread () {
 	RK_TRACE (RBACKEND);
+
+	default_sigsegv_handler = signal (SIGSEGV, SIG_DFL);
 	r_thread->start ();
 }
 
@@ -200,6 +231,7 @@
 		r_thread->pauseOutput (false); // see above
 		processRCallbackRequest (static_cast<RCallbackArgs *> (ev->data ()));
 	} else if ((ev->etype () == RKRBackendEvent::RStarted)) {
+		r_sigsegv_handler = signal (SIGSEGV, &sigsegv_proxy);
 		r_thread->unlock (RThread::Startup);
 		RKWardMainWindow::discardStartupOptions ();
 	} else if ((ev->etype () == RKRBackendEvent::RStartupError)) {

Modified: branches/KDE4_port/rkward/rbackend/rinterface.h
===================================================================
--- branches/KDE4_port/rkward/rbackend/rinterface.h	2007-11-22 14:01:55 UTC (rev 2265)
+++ branches/KDE4_port/rkward/rbackend/rinterface.h	2007-11-22 14:49:00 UTC (rev 2266)
@@ -20,8 +20,6 @@
 
 #include <qobject.h>
 #include <qmutex.h>
-//Added by qt3to4:
-#include <QCustomEvent>
 
 #include "rcommand.h"
 


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