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

Comments

Projects
None yet
3 participants
@romainfrancois
Copy link
Contributor

romainfrancois commented Mar 13, 2019

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-

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor Author

romainfrancois commented Mar 13, 2019

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

@eddelbuettel

This comment has been minimized.

Copy link
Member

eddelbuettel commented Mar 16, 2019

Done in #949. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.