[Rcpp-devel] Loading a package using Rcpp Modules results in memory corruption

Davor Cubranic cubranic at stat.ubc.ca
Tue Jan 11 19:12:13 CET 2011


I think an important point from Doug has been lost in the subsequent 20-odd messages of flamebombing:

>> I do not see this as compatible with the C++ Design principle we use whereby
>> protection / unprotection occurs relative to the end of scope -- and not
>> after every single assignment or allocation.
>> 
>> In other words, gctorture() may well be a fine test for the C API and its
>> PROTECT and UNPROTECT at every step but possibly not quite as much for Rcpp.
> 
> I don't think so.  In the situation that Dominick is describing the C
> API is being used (calls to Rf_install, Rf_lang1, Rf_eval, ...) and
> you have to play by the rules of the C API.  Essentially every time
> that you call a function in the C API that can cause a memory
> allocation you are open yourself to the possibility of having the
> garbage collector run and getting unprotected SEXPs blown away.  And,
> naturally, Rf_eval can cause memory allocation.
> 
> I understood Dominick to be saying that in the code related to Modules
> and the evaluator and all that which we have been trying to debug
> there are such cases of the use of the C API that are unsafe.

Can anyone comment whether this is correct?

Davor



More information about the Rcpp-devel mailing list