Hi Dirk and list,

I have now managed to isolate the problem. The cpp file posted below can on both Windows and 
Linux crash R if (a) compiled by winbuilder (windows only) or if build via 
devtools::load_all() or from within Rstudio ("Build & Reload") and (b) when 
using the appropriate input.

The following input crashes R:
  S <- 3
  Ineq <- structure(0, .Dim = c(1L, 1L))
But this input is okay:
  S <- 3
  Ineq <- structure(c(-1, 1, 0), .Dim = c(1L, 3L))

The c++ function producing the problem is (where SS = S and ineq = Ineq):

#### code follows ######

SEXP determinant2( SEXP SS, SEXP ineq){
BEGIN_RCPP

using namespace Rcpp;
using Eigen::Map;
using Eigen::VectorXd;
using Eigen::RowVectorXd;
using Eigen::MatrixXd;
const int S = Rcpp::as<int>(SS);
const Map<MatrixXd> Ineq(as<Map<MatrixXd> >(ineq));

RNGScope scope;

VectorXd thetaTMP;
RowVectorXd theta;
VectorXd IneqT;

thetaTMP = Rcpp::as<VectorXd>(rbeta(S, 0.5, 0.5));
theta = thetaTMP.transpose();

IneqT = (theta*Ineq.transpose());
return wrap(0);

END_RCPP
}

#### code ends ######

I have build a package which contains nothing but this code and two functions 
trigger() and no_trigger() the former of which crashes R and the latter does 
not crash R. The package can be found here: 
http://singmann.org/download/teaching/r/MPTbug_1.0.0.tar.gz
But as I said, when installing from source, the two functions work. Only when 
using the binary from winbuilder or building via devtools or RStudio does 
trigger() crash R. The winbuilder version can be found here (temporarily): 
http://win-builder.r-project.org/M4yLs8R7tFR1/

The problem obviously seems to be (theta*Ineq.transpose()) if Ineq is a scalar 
0. But why it works given one compilation and not the other is outside of my 
knowledge space. Any help would obviously be really appreciated.

Cheers,
Henrik

Am 15.10.2014 um 21:13 schrieb Dirk Eddelbuettel:

Hi Henrik,

On 15 October 2014 at 20:59, Henrik Singmann wrote:
| Dear list,
|
| I have the following weird problem and would be really glad for any input:
|
| The windows binary from CRAN for my package MPTinR, which uses RcppEigen, leads to an 
"Assertion failed" error which crashes R with a simple example given below 
(which unfortunately is not part of the examples and henceforth not tested by CRAN).
|
| Interestingly enough, the problem disappears when installing the package on 
Windows from source or when using Linux (Ubuntu). But it also appears when 
using a binary version of MPTinR from winbuilder (temporarily available here: 
http://win-builder.r-project.org/h18PJ7B55VAq), R-devel and corresponding 
binary from CRAN, and I could replicate the error on a range of different 
Windows machines. The error also always disappears when installing from source. 
I am also extremely confident that this problem didn't exist in the past, I and 
others have used this functionality regularly with the CRAN windows binary.
|
| ###### code starts #######
| require(MPTinR)
| data(d.broeder)
| m.2htm <- system.file("extdata", "5points.2htm.model", package = "MPTinR")
| get.mpt.fia(d.broeder, m.2htm)
| ###### code ends #######
|
| The complete error message is:
|
| ###### error message starts #######
| Assertion failed!
|
| Program: C:\Program Files\RStudio\bin\x64\rsession.exe
| File: 
d:/RCompile/CRANpkg/lib/3.1/RcppEigen/include/Eigen/src/Core/ProductBase.h, 
Line 95
|
| Expression: a_lhs.cols() == a_rhs.rows() && "invalid matrix product" && "if you 
wanted a coeff-wise or a dot product use the respective explicit functions"
|
| This application has requested the Runtime to terminate it in an unusual way.
| Please contact the application's support team for more information.
| ###### error message ends #######
|
| When adding such an example to the code and resubmitting it to winbuilder it 
now also crashes, see http://win-builder.r-project.org/0ei38q0t48h2/00check.log
| But again, when installing the same package on my machine from source it 
works.

It would help us if you could create a minimally reproducible example exhibit
this behaviour.

About 24 CRAN packages use RcppEigen.  The error could be yours, or ours. But
given the information provided so far it is hard to say more.

You could also try R along with valgrind on Linux to see if that tickles it.

Dirk


| Best,
| Henrik
|
| PS: A session info (without attaching MPTinR) is given below:
|
| R version 3.1.1 (2014-07-10)
| Platform: x86_64-w64-mingw32/x64 (64-bit)
|
| locale:
| [1] LC_COLLATE=German_Switzerland.1252  LC_CTYPE=German_Switzerland.1252    
LC_MONETARY=German_Switzerland.1252
| [4] LC_NUMERIC=C                        LC_TIME=German_Switzerland.1252
|
| attached base packages:
| [1] stats     graphics  grDevices utils     datasets  methods   base
|
| other attached packages:
| [1] devtools_1.6
|
| loaded via a namespace (and not attached):
| [1] fortunes_1.5-2 tools_3.1.1
|
|
|
| --
| Dr. Henrik Singmann
| Universität Zürich, Schweiz
| http://singmann.org
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel-Z+qqJ2/841ddxcdgmxqagq2ug9vpuwmkqh7oeaqu...@public.gmane.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


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

_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to