Illegal operand: installing and running an R package with rstan dependencies

I have been digging around, to try to understand why I do get the following error when I try to install and R package called ‘conStruct’. I do think that this imply some issues with compilation and some discordances related to the CPU used for compilation of Rstan and those used for the compilation of this other R package. But I’m new to this kind of issues and I do not know much.

I’m working in a SLURM cluster. And when I try to install the conStruct’ R package, I get the following error:

make: *** [stan_files/space_oneK.o] Error 1
rm stan_files/space_oneK.cc

ERROR: compilation failed for package ‘conStruct’

###Operating System
CentOS Linux 7

####Rstan verison
rstan Version 2.19.2

####.R/Makevars information:
CXX14FLAGS=-O3
CXX14FLAGS += -fPIC
CXX14FLAGS=-O3 -fPIC
CXX14=g++ -std=c++11

  • Output of devtools::session_info("rstan")
    setting value
    version R version 3.5.2 (2018-12-20)
    os CentOS Linux 7 (Core)
    system x86_64, linux-gnu
    ui X11
    language (EN)
    collate en_US.UTF-8
    ctype en_US.UTF-8
    tz Europe/Paris
    date 2019-10-04

Any idea how to debug the problem? Am I missing some useful information in my post?

My guess is that the compiler you are using does not support C++14 even if it accepts the flag, but we would need to see the whole installation log to be sure.

Thank you for your reply. I start clarifying my head.
Here it is:

** libs
“/tools/R/R-3.5.2/lib64/R/bin/Rscript” -e “source(file.path(‘…’, ‘tools’, ‘make_cc.R’)); make_cc(commandArgs(TRUE))” stan_files/space_oneK.stan
Wrote C++ file “stan_files/space_oneK.cc”

g++ -std=c++11 -I"/tools/R/R-3.5.2/lib64/R/include" -DNDEBUG -I"…/inst/include" -I"/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DBOOST_MATH_OVERFLOW_ERROR_POLICY=errno_on_error -I"/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include" -I"/work/user_id/softwares/R/3.5.2/lib/rstan/include" -I"/tools/R/R-3.5.2/lib64/R/library/BH/include" -I"/work/user_id/softwares/R/3.5.2/lib/Rcpp/include" -I"/tools/R/R-3.5.2/lib64/R/library/RcppEigen/include" -I/usr/local/include -O3 -fPIC -c stan_files/space_oneK.cc -o stan_files/space_oneK.o
In file included from /tools/R/R-3.5.2/lib64/R/library/BH/include/boost/random/detail/integer_log2.hpp:19:0,
from /tools/R/R-3.5.2/lib64/R/library/BH/include/boost/random/detail/large_arithmetic.hpp:19,
from /tools/R/R-3.5.2/lib64/R/library/BH/include/boost/random/detail/const_mod.hpp:23,
from /tools/R/R-3.5.2/lib64/R/library/BH/include/boost/random/linear_congruential.hpp:30,
from /tools/R/R-3.5.2/lib64/R/library/BH/include/boost/random/additive_combine.hpp:27,
from /work/user_id/softwares/R/3.5.2/lib/rstan/include/rstan/stan_fit.hpp:15,
from /work/user_id/softwares/R/3.5.2/lib/rstan/include/rstan/rstaninc.hpp:3,
from stan_files/space_oneK.hpp:18,
from stan_files/space_oneK.cc:3:
/tools/R/R-3.5.2/lib64/R/library/BH/include/boost/pending/integer_log2.hpp:7:89: note: #pragma message: This header is deprecated. Use <boost/integer/integer_log2.hpp> instead.
BOOST_HEADER_DEPRECATED(“<boost/integer/integer_log2.hpp>”);
^
In file included from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/fun/ordered_constrain.hpp:6:0,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat.hpp:41,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/src/stan/model/test_gradients.hpp:7,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10,
from /work/user_id/softwares/R/3.5.2/lib/rstan/include/rstan/stan_fit.hpp:35,
from /work/user_id/softwares/R/3.5.2/lib/rstan/include/rstan/rstaninc.hpp:3,
from stan_files/space_oneK.hpp:18,
from stan_files/space_oneK.cc:3:
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:31:32: error: ‘std::index_sequence’ has not been declared
std::index_sequence<I…> i) {
^
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:31:46: error: expected ‘,’ or ‘…’ before ‘<’ token
std::index_sequence<I…> i) {
^
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:31:54: warning: ‘apply_impl’ function uses ‘auto’ type specifier without trailing return type [enabled by default]
std::index_sequence<I…> i) {
^
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:48:48: warning: ‘apply’ function uses ‘auto’ type specifier without trailing return type [enabled by default]
constexpr auto apply(const F& f, const Tuple& t) {
^
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp: In function ‘constexpr auto stan::math::internal::apply(const F&, const Tuple&)’:
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:49:27: error: ‘make_index_sequence’ is not a member of ‘std’
return apply_impl(f, t, std::make_index_sequence<std::tuple_size{}>{});
^
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:49:27: note: suggested alternative:
In file included from /tools/R/R-3.5.2/lib64/R/library/BH/include/boost/fusion/container/vector/vector.hpp:28:0,
from /tools/R/R-3.5.2/lib64/R/library/BH/include/boost/fusion/container/vector/vector10.hpp:25,
from /tools/R/R-3.5.2/lib64/R/library/BH/include/boost/fusion/view/transform_view/transform_view.hpp:22,
from /tools/R/R-3.5.2/lib64/R/library/BH/include/boost/fusion/algorithm/transformation/transform.hpp:11,
from /tools/R/R-3.5.2/lib64/R/library/BH/include/boost/fusion/view/zip_view/detail/begin_impl.hpp:14,
from /tools/R/R-3.5.2/lib64/R/library/BH/include/boost/fusion/view/zip_view/zip_view.hpp:16,
from /tools/R/R-3.5.2/lib64/R/library/BH/include/boost/fusion/view/zip_view.hpp:12,
from /tools/R/R-3.5.2/lib64/R/library/BH/include/boost/fusion/include/zip_view.hpp:11,
from /tools/R/R-3.5.2/lib64/R/library/BH/include/boost/numeric/odeint/util/resize.hpp:26,
from /tools/R/R-3.5.2/lib64/R/library/BH/include/boost/numeric/odeint/util/state_wrapper.hpp:26,
from /tools/R/R-3.5.2/lib64/R/library/BH/include/boost/numeric/odeint/util/ublas_wrapper.hpp:33,
from /tools/R/R-3.5.2/lib64/R/library/BH/include/boost/numeric/odeint.hpp:25,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/prim/arr/functor/integrate_ode_rk45.hpp:17,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/prim/arr.hpp:46,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/prim/mat.hpp:344,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat.hpp:12,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/src/stan/model/test_gradients.hpp:7,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10,
from /work/user_id/softwares/R/3.5.2/lib/rstan/include/rstan/stan_fit.hpp:35,
from /work/user_id/softwares/R/3.5.2/lib/rstan/include/rstan/rstaninc.hpp:3,
from stan_files/space_oneK.hpp:18,
from stan_files/space_oneK.cc:3:
/tools/R/R-3.5.2/lib64/R/library/BH/include/boost/fusion/support/detail/index_sequence.hpp:59:12: note: ‘boost::fusion::detail::make_index_sequence’
struct make_index_sequence
^
In file included from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/fun/ordered_constrain.hpp:6:0,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat.hpp:41,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/src/stan/model/test_gradients.hpp:7,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10,
from /work/user_id/softwares/R/3.5.2/lib/rstan/include/rstan/stan_fit.hpp:35,
from /work/user_id/softwares/R/3.5.2/lib/rstan/include/rstan/rstaninc.hpp:3,
from stan_files/space_oneK.hpp:18,
from stan_files/space_oneK.cc:3:
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:49:77: error: expected primary-expression before ‘{’ token
return apply_impl(f, t, std::make_index_sequence<std::tuple_size{}>{});
^
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:49:77: error: expected ‘)’ before ‘{’ token
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp: At global scope:
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:151:9: error: expected type-specifier
= std::result_of_t<F(decltype(is_var_), decltype(value_of(Targs()))…)>;
^
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:156:42: error: ‘FReturnType’ was not declared in this scope
std::array<int, internal::compute_dims::value> M_;
^
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:156:53: error: template argument 1 is invalid
std::array<int, internal::compute_dims::value> M_;
^
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:156:61: error: template argument 2 is invalid
std::array<int, internal::compute_dims::value> M_;
^
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:408:39: warning: ‘operator()’ function uses ‘auto’ type specifier without trailing return type [enabled by default]
auto operator()(const Targs&… args) {
^
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp: In member function ‘std::vectorstan::math::var stan::math::adj_jac_vari<F, Targs>::build_return_varis_and_vars(const std::vector&)’:
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:349:9: error: invalid types ‘int[int]’ for array subscript
M_[0] = val_y.size();
^
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:350:32: error: invalid types ‘int[int]’ for array subscript
std::vector var_y(M_[0]);
^
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp: In member function ‘Eigen::Matrix<stan::math::var, R, C> stan::math::adj_jac_vari<F, Targs>::build_return_varis_and_vars(const Eigen::Matrix<double, R, C>&)’:
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:375:9: error: invalid types ‘int[int]’ for array subscript
M_[0] = val_y.rows();
^
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:376:9: error: invalid types ‘int[int]’ for array subscript
M_[1] = val_y.cols();
^
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:377:40: error: invalid types ‘int[int]’ for array subscript
Eigen::Matrix<var, R, C> var_y(M_[0], M_[1]);
^
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:377:47: error: invalid types ‘int[int]’ for array subscript
Eigen::Matrix<var, R, C> var_y(M_[0], M_[1]);
^
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp: In member function ‘void stan::math::adj_jac_vari<F, Targs>::chain()’:
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:530:5: error: ‘FReturnType’ was not declared in this scope
FReturnType y_adj;
^
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:530:17: error: expected ‘;’ before ‘y_adj’
FReturnType y_adj;
^
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:532:38: error: ‘y_adj’ was not declared in this scope
internal::build_y_adj(y_vi_, M_, y_adj);
^
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:536:26: error: expansion pattern ‘auto&&’ contains no argument packs
[this](auto&&… args) { this->accumulate_adjoints(args…); },
^
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp: In lambda function:
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:536:60: error: ‘args’ was not declared in this scope
[this](auto&&… args) { this->accumulate_adjoints(args…); },
^
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp: At global scope:
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:616:40: warning: ‘adj_jac_apply’ function uses ‘auto’ type specifier without trailing return type [enabled by default]
auto adj_jac_apply(const Targs&… args) {
^
In file included from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat.hpp:41:0,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/src/stan/model/test_gradients.hpp:7,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10,
from /work/user_id/softwares/R/3.5.2/lib/rstan/include/rstan/stan_fit.hpp:35,
from /work/user_id/softwares/R/3.5.2/lib/rstan/include/rstan/rstaninc.hpp:3,
from stan_files/space_oneK.hpp:18,
from stan_files/space_oneK.cc:3:
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/fun/ordered_constrain.hpp:61:62: warning: ‘multiply_adjoint_jacobian’ function uses ‘auto’ type specifier without trailing return type [enabled by default]
const Eigen::VectorXd& adj) const {
^
In file included from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat.hpp:42:0,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/src/stan/model/test_gradients.hpp:7,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10,
from /work/user_id/softwares/R/3.5.2/lib/rstan/include/rstan/stan_fit.hpp:35,
from /work/user_id/softwares/R/3.5.2/lib/rstan/include/rstan/rstaninc.hpp:3,
from stan_files/space_oneK.hpp:18,
from stan_files/space_oneK.cc:3:
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/fun/positive_ordered_constrain.hpp:62:62: warning: ‘multiply_adjoint_jacobian’ function uses ‘auto’ type specifier without trailing return type [enabled by default]
const Eigen::VectorXd& adj) const {
^
In file included from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat.hpp:48:0,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/src/stan/model/test_gradients.hpp:7,
from /work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10,
from /work/user_id/softwares/R/3.5.2/lib/rstan/include/rstan/stan_fit.hpp:35,
from /work/user_id/softwares/R/3.5.2/lib/rstan/include/rstan/rstaninc.hpp:3,
from stan_files/space_oneK.hpp:18,
from stan_files/space_oneK.cc:3:
/work/user_id/softwares/R/3.5.2/lib/StanHeaders/include/stan/math/rev/mat/fun/simplex_constrain.hpp:67:62: warning: ‘multiply_adjoint_jacobian’ function uses ‘auto’ type specifier without trailing return type [enabled by default]
const Eigen::VectorXd& adj) const {
^
make: *** [stan_files/space_oneK.o] Error 1
rm stan_files/space_oneK.cc
ERROR: compilation failed for package ‘conStruct’

  • removing ‘/work/user_id/softwares/R/3.5.2/lib/conStruct’
  • restoring previous ‘/work/user_id/softwares/R/3.5.2/lib/conStruct’
    Error: Failed to install ‘conStruct’ from GitHub:
    (converted from warning) installation of package ‘/tmp/RtmpCGfyni/fileaee4a678699/conStruct_1.0.3.tar.gz’ had non-zero exit status

q()

Looks like you’ll probably want this in order to get an up-to-date compiler: https://www.softwarecollections.org/en/scls/rhscl/devtoolset-8/

1 Like

Ok, but I’m not sure whether the compiler is the actual issue.
The reason why is that this R package has been already installed in the SLURM server (root library). It was installed in an older R version (R 3.4.3).

When I try to call the R package from the library of the older R version. I do obtain a similar type of error:

Loading required package: Rcpp

Loading required package: methods

*** caught illegal operation ***

address 0x7f31674c2b71, cause ‘illegal operand’

Again, I do not know what to look at to solve the issue.

Also, you have the C++11 standard hardcoded somewhere, whereas you need to be using C++14 (and have a compiler that supports it). But if you are getting a caught illegal operation just from loading a package, that would suggest to me that something is wrong with your R installation.

I solved this problems by loading the module for a more up-to-date compiler. I added ‘module load compiler/gcc-7.2.0’ in my script and re-installed the packages.

Thanks