On Thu, Oct 16, 2014 at 8:58 AM, John Buonagurio
<jbuonagurio at exponent.com> wrote:
Hi Henrik,
You can just add #define EIGEN_NO_DEBUG to make it clear that you want
to specifically disable Eigen assertions, without relying on what sets or
does not set the DNDEBUG flag. It's in the Eigen documentation:
-----Original Message-----
From: rcpp-devel-bounces at lists.r-forge.r-project.org [mailto:
bounces at lists.r-forge.r-project.org] On Behalf Of Henrik Singmann
Sent: Thursday, October 16, 2014 10:39 AM
To: Dirk Eddelbuettel
Cc: rcpp-devel at r-forge.wu-wien.ac.at
Subject: Re: [Rcpp-devel] RcppEigen: Windows binary from CRAN crashes
not when installing from source.
<html>
Hi Dirk,
I am sorry to address this again, as I am in no position to argue, but
is still the following:
The code runs perfectly as your example showed but will fail when using
devtools or winbuilder or CRAN when *inside a package*. The problem of
producing a minimally reproducible example of your liking is that
conditions cannot be met: I need the package to reproduce it.
I also agree that it is an issue of multiplying non-conformable
be easily shown using the code you had sent, when compiling it on owns
(i.e., not using the conditions reproducing the crash described above)
leads to a result of 0. However, when using the binary from either of
it crashes R with an assertion error.
It is also important to note that this did not happen in the past.
So I probably just need to set the correct compiler flags or disable
such a thing, but I did not manage to do this in such a way to prohibit
under the above described circumstances.
I would really like to receive any advice on how to avoid this crash
error) when using the binary compiled on CRAN, this is in the end the
issue. *How can I disable the assertion error compiling in my code?*
"#undef NDEBUG" at the beginning didn't work.
On an unrelated note, the issue of within package or outside of a
concerns the question of "using Eigen::..." versus prefacing all calls
parts with Eigen:: directly.
While the code you had sent works great when using sourceCpp(), I didn't
manage to get it to work in a package (even after wildly using
compileAttributes). I had to replace all calls of e.g., VectorXd with
Eigen::VectorXd. Is there a trick of how to do this inside a package?
Btw, I agree that using the RcppAttributes is great. I hadn't used it,
know, "never touch a running system." But as it failed now, it is
a change.
Thanks again,
Henrik
Am 16.10.2014 um 16:04 schrieb Dirk Eddelbuettel:
On 16 October 2014 at 08:35, Dirk Eddelbuettel wrote:
|
|
| On 16 October 2014 at 15:07, Henrik Singmann wrote:
| | Hi Dirk and Kevin,
| |
| | I have now rebuild the package using the code Dirk send me (i.e.,
attributes) and the code still reliably crashes my R on Linux when
(independent of RStudio), but not when installing via install.packages.
using the code Dirk had send directly (i.e., outside a package) this
|
| Please take that up with the devtools maintainer. I do not use
And FWIW he used confirmed over IM that devtools sets NDEBUG. So
there -- devtools issues, not an Rcpp or RcppEigen issue.
Dirk
| It is not part of what we asked for: __a minimally reproducible
| example__
|
| | Note that I had to minimally change the code Dirk had sent as I
manage to use "using Eigen::" so had to preface every call to Eigen
structures with "Eigen::".
|
| Here is my counter example. Ubuntu 14.04. Everything current.
|
| Save the following a file "henrik.cpp"
|
| --------------------------------------------------------------------
| ---------
|
| #include <RcppEigen.h>
|
| using namespace Rcpp;
|
| using Eigen::Map;
| using Eigen::VectorXd;
| using Eigen::RowVectorXd;
| using Eigen::MatrixXd;
|
| // [[Rcpp::depends(RcppEigen)]]
|
| // The following is __identical__ to mptmin::src/determinant.cpp //
| but at the same time much, much shorter and more readable // // The
| following 'tag' ensure determinant2() is accessible from R // //
| [[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
|
| # the following is equivalent to mptmin::R/minimal.cpp # but shorter
| and easier; also removed the leading dot
| oneSample2 <- function(Sx, Ineq) {
| #.Call("determinant2", Sx, Ineq, PACKAGE = "MPTbug")
| determinant2(Sx, Ineq)
| }
|
| # the dimensions are of course incompatible so this is user error
| trigger <- function() {
| S <- 3
| # why would you create a matrix via structure() ?
| Ineq <- structure(0, .Dim = c(1L, 1L)) #error
| oneSample2(Sx = S, Ineq = Ineq)
| }
|
| no_trigger <- function() {
| S <- 3
| Ineq <- structure(c(-1, 1, 0), .Dim = c(1L, 3L)) # no error
| oneSample2(Sx = S, Ineq = Ineq)
| }
|
| no_trigger() # no issue
| trigger() # no issue either
| */
|
| --------------------------------------------------------------------
| ---------
|
|
| In an R session, issue the following command
| sourceCpp("filename.cpp") with the name (plus optional path) to the
| file above. Here is what I get in a fresh session:
|
| --------------------------------------------------------------------
| ---------
| R> Rcpp::sourceCpp("~/Dropbox/tmp/henrik.cpp")
|
| R> # the following is equivalent to mptmin::R/minimal.cpp # but
| R> shorter and easier; also removed the leading dot
| R> oneSample2 <- function(Sx, In .... [TRUNCATED]
|
| R> # the dimensions are of course incompatible so this is user error
| R> trigger <- function() {
| + S <- 3
| + # why would you create a matrix via str .... [TRUNCATED]
|
| R> no_trigger <- function() {
| + S <- 3
| + Ineq <- structure(c(-1, 1, 0), .Dim = c(1L, 3L)) # no error
| + oneSample2(Sx = S, Ineq = Ineq)
| + }
|
| R> no_trigger() # no issue
| [1] 0
|
| R> trigger() # no issue either
| [1] 0
| R>
| --------------------------------------------------------------------
| ---------
|
| I consider this issue closed because __there is still no minimal
| reproducible bug__.
|
| There is what we could call a user error. Or if you wish a design
| error. You simply cannot multiply non-conformant vectors.
|
| Dirk