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

[rchk] Stack imbalance in RcppExports.cpp #948

Closed
romainfrancois opened this issue Mar 13, 2019 · 3 comments
Closed

[rchk] Stack imbalance in RcppExports.cpp #948

romainfrancois opened this issue Mar 13, 2019 · 3 comments

Comments

@romainfrancois
Copy link
Contributor

I'm getting many variations of :

Function _dplyr_grouped_df_impl
  [UP] ignoring variable <unnamed var:   %22 = alloca %struct.SEXPREC*, align 8> as it has address taken, results will be incomplete 
  [PB] has possible protection stack imbalance /opt/R-svn/packages/build/6XQsgOpC/dplyr/src/RcppExports.cpp:254

from the rchk results. I believe this is because of the VOID_END_RCPP macro:

#ifndef VOID_END_RCPP
#define VOID_END_RCPP                                                                            \
    }                                                                                            \
    catch( Rcpp::internal::InterruptedException &__ex__) {                                       \
        rcpp_output_type = 1 ;                                                                   \
    }                                                                                            \
    catch (Rcpp::LongjumpException& __ex__) {                                                    \
        rcpp_output_type = 3 ;                                                                   \
        rcpp_output_condition = __ex__.token;                                                    \
    }                                                                                            \
    catch(Rcpp::exception& __ex__) {                                                             \
       rcpp_output_type = 2 ;                                                                    \
       rcpp_output_condition = PROTECT(rcpp_exception_to_r_condition(__ex__)) ;                  \
    }                                                                                            \
    catch( std::exception& __ex__ ){                                                             \
       rcpp_output_type = 2 ;                                                                    \
       rcpp_output_condition = PROTECT(exception_to_r_condition(__ex__)) ;                       \
    }                                                                                            \
    catch( ... ){                                                                                \
       rcpp_output_type = 2 ;                                                                    \
       rcpp_output_condition = PROTECT(string_to_try_error("c++ exception (unknown reason)")) ;  \
    }                                                                                            \
    if( rcpp_output_type == 1 ){                                                                 \
       Rf_onintr() ;                                                                             \
    }                                                                                            \
    if( rcpp_output_type == 2 ){                                                                 \
       SEXP stop_sym  = Rf_install( "stop" ) ;                                                   \
       SEXP expr = PROTECT( Rf_lang2( stop_sym , rcpp_output_condition ) ) ;                     \
       Rf_eval( expr, R_GlobalEnv ) ;                                                            \
    }                                                                                            \
    if (rcpp_output_type == 3) {                                                                 \
        Rcpp::internal::resumeJump(rcpp_output_condition);                                       \
    }
#endif

which PROTECT() but never UNPROTECT()

I understand that there is a stop call, however rchk does not seem to understand that.

ping @lionel-

@lionel-
Copy link
Contributor

lionel- commented Mar 13, 2019

I guess it makes sense to unprotect just to help static analysis?

Rf_eval( expr, R_GlobalEnv ) ;

This should also be R_BaseEnv.

@romainfrancois
Copy link
Contributor Author

That's what I'm thinking too, I'm working on a branch.

@eddelbuettel
Copy link
Member

Done in #949. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants