[Rinside-commits] r183 - in pkg: . src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jan 20 22:38:41 CET 2011


Author: edd
Date: 2011-01-20 22:38:40 +0100 (Thu, 20 Jan 2011)
New Revision: 183

Modified:
   pkg/ChangeLog
   pkg/src/RInside.cpp
Log:
correct use of Rf_install based on Doug's debugging based on Luke's work with unprotected SEXPs inside R
short story is that once symbol is in symbol table it is safe from gc(), so assigning Rf_install to SEXPs


Modified: pkg/ChangeLog
===================================================================
--- pkg/ChangeLog	2010-12-26 16:47:44 UTC (rev 182)
+++ pkg/ChangeLog	2011-01-20 21:38:40 UTC (rev 183)
@@ -1,3 +1,8 @@
+2011-01-20  Dirk Eddelbuettel  <edd at debian.org>
+
+	* src/RInside.cpp (initialize): Assign results of Rf_install to avoid
+	any risk of garbage collection -- with thaks to Doug and Luke
+
 2010-12-26  Dirk Eddelbuettel  <edd at debian.org>
 
 	* src/RInside.cpp (initialize): If Rcpp is requested, load it

Modified: pkg/src/RInside.cpp
===================================================================
--- pkg/src/RInside.cpp	2010-12-26 16:47:44 UTC (rev 182)
+++ pkg/src/RInside.cpp	2011-01-20 21:38:40 UTC (rev 183)
@@ -118,9 +118,12 @@
     global_env = R_GlobalEnv ;
     
     if (loadRcpp) {			// if asked for, load Rcpp (before the autoloads)
-	Rf_eval(Rf_lang2(Rf_install( "suppressMessages" ), 
-			 Rf_lang2(Rf_install( "require" ), Rf_mkString("Rcpp"))),
-		R_GlobalEnv);
+	// Rf_install is used best by first assigning like this so that symbols get into the symbol table 
+	// where they cannot be garbage collected; doing it on the fly does expose a minuscule risk of garbage  
+	// collection -- with thanks to Doug Bates for the explanation and Luke Tierney for the heads-up
+	SEXP suppressMessagesSymbol = Rf_install("suppressMessages");
+	SEXP requireSymbol = Rf_install("require");
+	Rf_eval(Rf_lang2(suppressMessagesSymbol, Rf_lang2(requireSymbol, Rf_mkString("Rcpp"))), R_GlobalEnv);
     }
 
     autoloads();    			// loads all default packages



More information about the Rinside-commits mailing list