Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gc protection problem in dplyr code #998

Closed
spkal opened this issue Feb 28, 2015 · 3 comments
Closed

gc protection problem in dplyr code #998

spkal opened this issue Feb 28, 2015 · 3 comments
Assignees
Milestone

Comments

@spkal
Copy link

spkal commented Feb 28, 2015

The assignment below (several instances of which exist in dplyr.cpp) has a gc protection problem: the object returned by shallow_copy(data) is unprotected upon return, while the DataFrame_Impl constructor (highlighted with __ below) creating the copy object will do an allocation in the default Vector constructor (from which DataFrame_Impl inherits) that will collect the unprotected result of shallow_copy(data) before it can be protected by the set__(x) call in the DataFrame_Impl constructor.

// -- dplyr.cpp
    DataFrame copy = shallow_copy(data) ;

// -- DataFrame.h
    template <template <class> class StoragePolicy>
    class DataFrame_Impl : __public Vector<VECSXP, StoragePolicy>__ {
    public:
        typedef Vector<VECSXP, StoragePolicy> Parent ;

        DataFrame_Impl() : Parent( internal::empty_data_frame() ){}
        DataFrame_Impl(SEXP x) {
            set__(x);
        }

// -- Vector.h  (in Rcpp)
    Vector() {
      Storage::set__( Rf_allocVector(RTYPE, 0 ) );
      init() ;
    }  
@hadley hadley added this to the 0.4.2 milestone May 19, 2015
@hadley
Copy link
Member

hadley commented May 19, 2015

@romainfrancois is this now fixed?

@romainfrancois
Copy link
Member

Note sure. I'll have a look.

@romainfrancois romainfrancois self-assigned this May 23, 2015
@romainfrancois
Copy link
Member

This looks like a problem in Rcpp. I have:

  • put a workaround for dplyr for now.
  • submitted a PR to Rcpp for an upstream fix of the problem

@lock lock bot locked as resolved and limited conversation to collaborators Jun 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants