Skip to content

Solution to [Rcpp-devel] Runtime error from Rcpp::depends with gcc sanitizers #1112

@boennecd

Description

@boennecd

I ran into the exact issue described in this post. As I could not figure out whether this has been solved, then I post a solution here. The cause of the problem seems to be uninitialized bools. This is easy to confirm. First, consider the setup in the mailing list:

docker run -it --rm rhub/rocker-gcc-san bash
Rdevel -e "install.packages('remotes')"
Rdevel -e "remotes::install_github('boennecd/Rcpp', ref = 'c5a97a3')"
Rdevel -e "Rcpp::sourceCpp(code = '
#include <Rcpp.h>
// [[Rcpp::depends(Matrix)]]
// [[Rcpp::export]]
int foo() { return 0; }')"

This still yields:

attributes.cpp:169:11: runtime error: load of value 2, which is not a valid value for type 'bool'

The error is removed when one initalize the private members as I have done in the repository I install here:

Rdevel -e "remotes::install_github('boennecd/Rcpp', ref = 'abff123')"
Rdevel -e "Rcpp::sourceCpp(code = '
#include <Rcpp.h>
// [[Rcpp::depends(Matrix)]]
// [[Rcpp::export]]
int foo() { return 0; }')"

There is no error in this case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions