[Rcpp-devel] RcppEigen: Windows binary from CRAN crashes R, but not when installing from source.

Henrik Singmann henrik.singmann at psychologie.uni-freiburg.de
Thu Oct 16 15:07:24 CEST 2014


Hi Dirk and Kevin,

I have now rebuild the package using the code Dirk send me (i.e., using attributes) and the code still reliably crashes my R on Linux when using devtools (independent of RStudio), but not when installing via install.packages. When just using the code Dirk had send directly (i.e., outside a package) this does not happen.

Note that I had to minimally change the code Dirk had sent as I couldn't manage to use "using Eigen::" so had to preface every call to Eigen functions or structures with "Eigen::".

Following are the exact steps needed to crash R from a Linux console:

Thanks a lot,
Henrik

#######################

# get the package:
wget http://singmann.org/download/teaching/r/MPTbug_1.0.0.tar.gz
tar -zxvf MPTbug_1.0.0.tar.gz

# I first use devtools to build and then crash R:
cd MPTbug
R
require(devtools)
load_all(recompile = TRUE)
trigger()  #this crashes R, error message is given below, but the same as before.


### Compiling messages:
Loading MPTbug
Re-compiling MPTbug
'/usr/lib64/R/bin/R' --vanilla CMD INSTALL '/home/singmann/MPTbug' \
   --library='/tmp/Rtmp3vi8kf' --no-R --no-data --no-help --no-demo --no-inst  \
   --no-docs --no-exec --no-multiarch --no-test-load --preclean

* installing *source* package ‘MPTbug’ ...
** libs
g++ -m64 -I/usr/include/R -DNDEBUG -I. -I../inst/include -I/usr/local/include -I"/home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/Rcpp/include" -I"/home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include" -UNDEBUG -Wall -pedantic -g -O0 -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches  -m64 -mtune=generic -flto -c RcppExports.cpp -o RcppExports.o
In file included from /home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/Eigen/Cholesky:24:0,
                  from /home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/Eigen/Dense:3,
                  from /home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/RcppEigenForward.h:30,
                  from /home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/RcppEigen.h:25,
                  from RcppExports.cpp:4:
/home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/Eigen/src/Cholesky/LDLT.h: In member function ‘void Eigen::internal::solve_retval<Eigen::LDLT<MatrixType, _UpLo>, Rhs>::evalTo(Dest&) const’:
/home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/Eigen/src/Cholesky/LDLT.h:505:39: warning: typedef ‘Scalar’ locally defined but not used [-Wunused-local-typedefs]
      typedef typename LDLTType::Scalar Scalar;
                                        ^
g++ -m64 -I/usr/include/R -DNDEBUG -I. -I../inst/include -I/usr/local/include -I"/home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/Rcpp/include" -I"/home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include" -UNDEBUG -Wall -pedantic -g -O0 -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches  -m64 -mtune=generic -flto -c determinant2.cpp -o determinant2.o
In file included from /home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/Eigen/Cholesky:24:0,
                  from /home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/Eigen/Dense:3,
                  from /home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/RcppEigenForward.h:30,
                  from /home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/RcppEigen.h:25,
                  from determinant2.cpp:1:
/home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/Eigen/src/Cholesky/LDLT.h: In member function ‘void Eigen::internal::solve_retval<Eigen::LDLT<MatrixType, _UpLo>, Rhs>::evalTo(Dest&) const’:
/home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/Eigen/src/Cholesky/LDLT.h:505:39: warning: typedef ‘Scalar’ locally defined but not used [-Wunused-local-typedefs]
      typedef typename LDLTType::Scalar Scalar;
                                        ^
g++ -m64 -shared -Wl,-z,relro -o MPTbug.so RcppExports.o determinant2.o -L/usr/lib64/R/lib -lR
installing to /tmp/Rtmp3vi8kf/MPTbug/libs
* DONE (MPTbug)


### Error message (which is the same as from winbuilder/CRAN binary):
 > trigger()
R: /home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/Eigen/src/Core/ProductBase.h:95: Eigen::ProductBase<Derived, Lhs, Rhs>::ProductBase(const Lhs&, const Rhs&) [with Derived = Eigen::GeneralProduct<Eigen::Matrix<double, 1, -1>, Eigen::Transpose<Eigen::Map<Eigen::Matrix<double, -1, -1> > >, 4>; Lhs = Eigen::Matrix<double, 1, -1>; Rhs = Eigen::Transpose<Eigen::Map<Eigen::Matrix<double, -1, -1> > >]: Assertion `a_lhs.cols() == a_rhs.rows() && "invalid matrix product" && "if you wanted a coeff-wise or a dot product use the respective explicit functions"' failed.
Aborted (core dumped)


#### However, when installing from the source package, everything works. See following code and compiler messages.

cd ..
R
install.packages("MPTbug_1.0.0.tar.gz", repos = NULL)
require(MPTbug)
trigger()


#### compiler:

 > install.packages("MPTbug_1.0.0.tar.gz", repos = NULL)
Installing package into ‘/home/singmann/R/x86_64-redhat-linux-gnu-library/3.1’
(as ‘lib’ is unspecified)
* installing *source* package ‘MPTbug’ ...
** libs
g++ -m64 -I/usr/include/R -DNDEBUG -I. -I../inst/include -I/usr/local/include -I"/home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/Rcpp/include" -I"/home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include" -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches  -m64 -mtune=generic -flto -c RcppExports.cpp -o RcppExports.o
In file included from /home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/Eigen/Cholesky:24:0,
                  from /home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/Eigen/Dense:3,
                  from /home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/RcppEigenForward.h:30,
                  from /home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/RcppEigen.h:25,
                  from RcppExports.cpp:4:
/home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/Eigen/src/Cholesky/LDLT.h: In member function ‘void Eigen::internal::solve_retval<Eigen::LDLT<MatrixType, _UpLo>, Rhs>::evalTo(Dest&) const’:
/home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/Eigen/src/Cholesky/LDLT.h:505:39: warning: typedef ‘Scalar’ locally defined but not used [-Wunused-local-typedefs]
      typedef typename LDLTType::Scalar Scalar;
                                        ^
g++ -m64 -I/usr/include/R -DNDEBUG -I. -I../inst/include -I/usr/local/include -I"/home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/Rcpp/include" -I"/home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include" -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches  -m64 -mtune=generic -flto -c determinant2.cpp -o determinant2.o
In file included from /home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/Eigen/Cholesky:24:0,
                  from /home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/Eigen/Dense:3,
                  from /home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/RcppEigenForward.h:30,
                  from /home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/RcppEigen.h:25,
                  from determinant2.cpp:1:
/home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/Eigen/src/Cholesky/LDLT.h: In member function ‘void Eigen::internal::solve_retval<Eigen::LDLT<MatrixType, _UpLo>, Rhs>::evalTo(Dest&) const’:
/home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/RcppEigen/include/Eigen/src/Cholesky/LDLT.h:505:39: warning: typedef ‘Scalar’ locally defined but not used [-Wunused-local-typedefs]
      typedef typename LDLTType::Scalar Scalar;
                                        ^
g++ -m64 -shared -Wl,-z,relro -o MPTbug.so RcppExports.o determinant2.o -L/usr/lib64/R/lib -lR
installing to /home/singmann/R/x86_64-redhat-linux-gnu-library/3.1/MPTbug/libs
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
   converting help for package ‘MPTbug’
     finding HTML links ... done
     trigger                                 html
** building package indices
** testing if installed package can be loaded
* DONE (MPTbug)





Am 16.10.2014 um 00:19 schrieb Dirk Eddelbuettel:
> (Headers once more corrected)
>
> On 15 October 2014 at 14:53, Kevin Ushey wrote:
> |
> |
> |
> | Hi Henrik,
> |
> | Thanks for putting this together. FWIW, I cannot reproduce this error
> | (either with `trigger()` or `no_trigger()`) on OS X, nor when building
> | from source on a Windows VM (while inside RStudio).
> |
> | I also tried running the address and undefined behavior sanitizers
> | when executing the code and nothing was picked up.
> |
> | Can you post the compiler output you get when using
> | `devtools::load_all()` vs. a regular `R CMD INSTALL` ? I wonder if the
> | compile flags are somehow different and if that could lead to a
> | problem.
> |
> | Can you also elaborate on how you can reproduce this on Linux? This is
> | the environment we're most familiar with and so if we can reproduce
> | there then we can most easily discover a solution. I wonder if using
> | `gctorture(TRUE)` before running `trigger()` would make the assertion
> | failure more likely.
>
> I second Kevin's comments.  I have an outstanding request with Dortmund for
> something regarding another package where I also suspect a configuration
> issue; this may be as trivial as the Windows binary there being out of sync.
>
> Your code seems fine.  Below is how I would write it, in a self-contained
> short snippet you can just 'sourceCpp()' and which will even executed the
> short R portion making it truly reproducible and self-contained.
>
> It shows no issue.  This may be a one-off related to win-builder.
>
> Thanks, Dirk
>
>
>
> #include <RcppEigen.h>
>
> using namespace Rcpp;
>
> using Eigen::Map;
> using Eigen::VectorXd;
> using Eigen::RowVectorXd;
> using Eigen::MatrixXd;
>
> // [[Rcpp::depends(RcppEigen)]]
>
> // [[Rcpp::export]]
> int determinant2(int S, Map<MatrixXd> Ineq) {
>
>      VectorXd thetaTMP = Rcpp::as<VectorXd>(rbeta(S, 0.5, 0.5));
>      RowVectorXd theta = thetaTMP.transpose();
>
>      VectorXd IneqT = (theta*Ineq.transpose());
>
>      return 0;
> }
>
> /*** R
> determinant2(2, matrix(1.0*(1:4),2,2))
> */
>
>

-- 
Dr. Henrik Singmann
PostDoc
Universität Zürich, Schweiz
http://singmann.org


More information about the Rcpp-devel mailing list