[Rcpp-devel] R.e. loadRcppModules
bates at stat.wisc.edu
Tue Apr 12 16:06:46 CEST 2011
On Tue, Apr 12, 2011 at 1:11 AM, Romain Francois
<romain at r-enthusiasts.com> wrote:
> Le 12/04/11 04:15, Christian Gunning a écrit :
>> On Mon, Apr 11, 2011 at 3:00 AM,
>> <rcpp-devel-request at r-forge.wu-wien.ac.at> wrote:
>>> This will load the declared modules, and populate them into your
>>> package's namespace.
>>> I will update the Rcpp-modules vignette accordingly.
>>> Suggestions, comments, improvements, "what are you ? nuts !", ... are
>>> always welcome.
>> Works great for me -- very cool.
>> One question that's been bothering me -- how are module-based objects
>> *supposed* to behave across an R session quit/save/restart cycle? I'm
>> seeing no persistence, and a consistent segfault. Am I missing
>> something here (perhaps wrt finalizer)? If not, I'd like to add a
>> note to the vignette...
> Yes. This is a problem.
> Not sure how this could be dealt with, but at least we should document that
> there is no persistence yet.
The documented behavior is that an external pointer is replaced by a
null pointer when an object is serialized. I was planning to
experiment with an object that has enough information saved as R
objects to be able to regenerate the C++ object and an external
pointer to the module instance. The methods that use the object will
check first to see if the pointer is null, in which case they will
regenerate the module instance, otherwise go directly to invoking
methods on the module instance.
I doubt that I will be able to get to this until next week as I have
our Master's exam reports to read starting at 11:00 this morning.
>> Using the supplied example, I get:
>> Rcpp.package.skeleton('testpkg1', module=T)
>> modtest<- new(World)
>> ## everything works
>> ## Save workspace image? [y/n/c]: y
>> ## exit, save, restart -- nothing works
>> # [Previously saved workspace restored]
>> # During startup - Warning message:
>> # Class "C++Object" is defined (with package slot ‘Rcpp’) but no
>> metadata object found to revise subclass information---not exported?
>> Making a copy in package ‘.GlobalEnv’
>> #Error in .External(list(name = "CppMethod__invoke_notvoid", address =
>> <pointer: (nil)>, :
>> # NULL value passed as symbol address
>> *** caught segfault ***
>> address 0x8, cause 'memory not mapped'
>> 1: .Call(Class__name, cppclass)
>> 2: sprintf("C++ object<%s> of class '%s'<%s>",
>> externalptr_address(pointer), .Call(Class__name, cppclass),
>> 3: show(modtest)
>> 4: show(modtest)
>> Possible actions:
>> 1: abort (with core dump, if enabled)
>> 2: normal R exit
>> 3: exit R without saving workspace
>> 4: exit R saving workspace
>> Selection: 1
>> aborting ...
>> Segmentation fault
> Romain Francois
> Professional R Enthusiast
> +33(0) 6 28 91 30 30
> |- http://bit.ly/fhqbRC : Rcpp workshop in Chicago on April 28th
> |- http://bit.ly/dFyZGB : Hydraulique au Montpellier Comedie Club
> `- http://bit.ly/eVXit9 : Eponyme : 40 minutes stand up
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
More information about the Rcpp-devel