<div dir="ltr">darn.  i R CMD check'd --as-cran under R-devel and also loaded the minimal package, sparseList_1.1, the example and test run without issue​<br><div class="gmail_chip gmail_drive_chip" style="width:396px;height:18px;max-height:18px;background-color:#f5f5f5;padding:5px;color:#222;font-family:arial;font-style:normal;font-weight:bold;font-size:13px;border:1px solid #ddd;line-height:1">
<a href="https://docs.google.com/file/d/0B0DIDcaf6yMwZDRDZUNLd0lBbmZ3OHlHSzIyeV9hZ3RxZ0xr/edit?usp=drive_web" target="_blank" style="display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-decoration:none;padding:1px 0px;border:none;width:100%"><img style="vertical-align: bottom; border: none;" src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png"> <span dir="ltr" style="color:#15c;text-decoration:none;vertical-align:bottom">sparseList_1.1.tar.gz</span></a></div>
​.  So I'm stumped why the test is failing for you and not me.  I attach the file, again, just in I included the wrong version.  Sorry I wasn't able to get you a link that you could wget.  I work in the U.S. federal system and am limited by security protocols in what I'm able to do.  Thanks for being patient.<div>
<br></div><div>Since I include the data object (which requires both the spam and Matrix packages), I can/will remove the dependencies on those packages.  Since I have an example written into the documentation that runs on check, I will remove the test I added (and, therefore, testthat).   I will do this in the next day or so, assuming what I attached still doesn't work.</div>
<div><br></div><div>Stepping back, the code works in both the minimal package and growfunctions - it inputs a list of dgCMatrix objects, assigns the elements to a field<sp_mat> object and then writes it back out to a List object.  The elements of the outputted list object at the R layer are, indeed, dgCMatrix objects.   So 'yes', the script you referenced does create a valid dgCMatrix object and i've verified such. </div>
<div><div><br></div><div>As an aside, the C++ file embeds an R script that Kevin asked for if that is useful.</div></div><div><br></div><div>terrance.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Aug 9, 2014 at 7:14 PM, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Terrance,<br>
<div class=""><br>
On 9 August 2014 at 18:23, terrance savitsky wrote:<br>
| Hi Dirk, The revised version of this toy package, sparseList, does exactly what<br>
| you request.  I've included a data set that is of the same construction (of<br>
| dgCMatrix elements from R::Matrix wrapped into a list object) and have added<br>
| both an example and test that call this data.  The package is minimal, with a<br>
| simple .cpp function (that reads in the list of dgCMatrix objects and<br>
| writes the elements to an arma::field<arma:sp_mat>)  to isolate the source of<br>
| the error in growfunctions.<br>
|  <br>
| I attach the tarball, which you may also access through the following URL:<br>
|  <br>
| <a href="https://drive.google.com/file/d/" target="_blank">https://drive.google.com/file/d/</a><br>
| 0B0DIDcaf6yMwZDRDZUNLd0lBbmZ3OHlHSzIyeV9hZ3RxZ0xr/edit?usp=sharing<br>
<br>
</div>Did not work via wget, required a webpage visit and download.<br>
<br>
Package has extraneous dependencies (you do not need testthat to call a function).<br>
<br>
Moreover, testthat seems to pivot over to /usr/bin/R rather than Rdevel (not<br>
your issues, but you're not helping as it is not a minimally reproducible<br>
example).<br>
<br>
You also still import / depend on spam. Why?<br>
<div class=""><br>
| I hope this gives you what you need and thanks very much for looking into this.<br>
<br>
</div>I does blow up when I do<br>
<br>
   > library(sparseList)<br>
   Loading required package: Rcpp<br>
   > data(C)<br>
   > sparse_list <- manip_sparseList(C)<br>
<br>
and it similarly blows up when R CMD check runs the examples.<br>
<br>
<br>
<br>
But the question is whether your code which does<br>
<br>
    ## ...<br>
<br>
    ## convert to dcgmatrices (under Matrix package) required for sparse representation<br>
    ## as sp_mats in RcppArmadillo<br>
    C[[k]]               <- as(C[[k]], "dgCMatrix")<br>
<br>
<br>
creates a valid dgCMatrix. I do not know.<br>
<br>
RcppArmadillo is used by 77 packages on CRAN.  Prof Ripley checks all of<br>
those via valgrind and ASAN.  Only yours threw an error.<br>
<br>
I am not yet convinced this is our issue. I could of course be wrong.<br>
<br>
Anyway, I won't be able to look at this for few days. Moreover, I do not use<br>
sparse matrices -- so you may need to rely on someone else to debug this for<br>
you, or do it yourself.<br>
<br>
Sorry, Dirk<br>
<br>
|  <br>
| Terrance<br>
| ​<br>
| [icon_10_ge] sparseList_1.1.tar.gz<br>
<div class="HOEnZb"><div class="h5">| ​<br>
|<br>
|<br>
| On Sat, Aug 9, 2014 at 5:25 PM, Dirk Eddelbuettel <<a href="mailto:edd@debian.org">edd@debian.org</a>> wrote:<br>
|<br>
|<br>
|     Hi Terrance,<br>
|<br>
|     On 9 August 2014 at 16:58, terrance savitsky wrote:<br>
|     | Hi Guys, <br>
|     |  <br>
|     | I embed a data list object of dgCMatrix elements (produced in the same<br>
|     manner<br>
|     | as used in package, growfunctions) in an .RData file located in the<br>
|     sparseList<br>
|     | \data folder. I'm not sure what script and data ASAN uses to conduct the<br>
|     memory<br>
|     | check.  I'm guessing the package examples are run.  So I added an example<br>
|     that<br>
|     | loads the .RData object embedded with this toy package, sparseList. <br>
|     Please<br>
|     | pardon me if my understanding is off.   I also embedd an R script in the<br>
|     single<br>
|<br>
|     It's not complicated.<br>
|<br>
|     'R CMD check' needs a code path that does this, which can be as simple as<br>
|     an<br>
|     example section in the manual page (mayne you meant this by 'added an<br>
|     example').  Or something tickled via a test script in tests/.<br>
|<br>
|     You submitted a CRAN package. It has testable code. It failed. We now need<br>
|     a<br>
|     _minimal reproducible example_, ideally without a long tail of<br>
|     dependencies,<br>
|     to examine it.<br>
|<br>
|     | toy package .cpp file that generates the same data (list object of<br>
|     dgCMatrix<br>
|     | objects created using R::Matrix) and runs an example.<br>
|     |  <br>
|     | Terrance<br>
|     | ​<br>
|     |<br>
|     | [icon_10_ge] sparseList_1.1.tar.gz<br>
|<br>
|     Can you update to a version which loads data and passes down to the code<br>
|     which was seen to tickle this?<br>
|<br>
|     And then place it somewhere where we can get it with a simple wget or curl<br>
|     call.<br>
|<br>
|     Thanks, Dirk<br>
|      ​<br>
|<br>
|     |<br>
|     | On Sat, Aug 9, 2014 at 3:02 PM, Kevin Ushey <<a href="mailto:kevinushey@gmail.com">kevinushey@gmail.com</a>> wrote:<br>
|     |<br>
|     |     Hi Terrance,<br>
|     |<br>
|     |     Can you please try to construct a reproducible example based on the<br>
|     |     (tagged, potentially offending) line of code -- that is,<br>
|     |<br>
|     |         #4 0x7f79b6541df0 in IGMRFDPMIX<br>
|     |     /data/gannet/ripley/R/packages/tests-49x/growfunctions/src/<br>
|     dpmix.cpp:63<br>
|     |<br>
|     |     which has the line:<br>
|     |<br>
|     |         C(k,0)          = as<sp_mat>(Cr[k]);<br>
|     |<br>
|     |     Can you construct a small, reproducible example using objects 'C',<br>
|     |     'Cr' as you construct in the package, and then see if that gives a<br>
|     |     similar error?<br>
|     |<br>
|     |     Preferably you can construct this using Rcpp Attributes, so an<br>
|     example<br>
|     |     of the form<br>
|     |<br>
|     |         // [[Rcpp::depends(RcppArmadillo)]]<br>
|     |<br>
|     |         #include <RcppArmadillo.h><br>
|     |         using namespace Rcpp;<br>
|     |<br>
|     |         // [[Rcpp::export]]<br>
|     |         SEXP test(SEXP C, SEXP Cr) {<br>
|     |           ... use C, Cr as above...<br>
|     |         }<br>
|     |<br>
|     |         /*** R<br>
|     |         ... construct C, Cr on the R side as necessary ...<br>
|     |         */<br>
|     |<br>
|     |     That way, we can 'sourceCpp' it and immediately investigate.<br>
|     |<br>
|     |     Thanks,<br>
|     |     Kevin<br>
|     |<br>
|     |     On Sat, Aug 9, 2014 at 11:31 AM, terrance savitsky <<a href="mailto:tds151@gmail.com">tds151@gmail.com</a>><br>
|     |     wrote:<br>
|     |     > Dirk,  Thanks much for taking the time to investigate this issue.<br>
|      I've<br>
|     |     > created a package (sparseList_1.0.tar.gz) with a minimal example of<br>
|     what<br>
|     |     > writing from a list of dgCMatrix matrices at the R layer to a field<br>
|     |     <sp_mat>.<br>
|     |     > I had intended to install boot2docker and use load your R-devel<br>
|     set-up to<br>
|     |     a<br>
|     |     > container so that I could replicate the ASAN-generated error.  Its<br>
|     taking<br>
|     |     me<br>
|     |     > longer than I'd hoped, however, so - for now - I include the<br>
|     package<br>
|     |     tarball<br>
|     |     > with the minimal example and also an R script<br>
|     (sparse_list_to_field.R) so<br>
|     |     > that you may see what the function does.<br>
|     |     > Terrance<br>
|     |     >  sparse_list_to_field.R<br>
|     |     ><br>
|     |     >  sparseList_1.0.tar.gz<br>
|     |     ><br>
|     |     ><br>
|     |     ><br>
|     |     > On Sat, Aug 9, 2014 at 11:50 AM, Dirk Eddelbuettel <<a href="mailto:edd@debian.org">edd@debian.org</a>><br>
|     |     wrote:<br>
|     |     >><br>
|     |     >><br>
|     |     >> Terrance,<br>
|     |     >><br>
|     |     >> So I took a look with one of the prebuilt versions of R using the<br>
|     Docker<br>
|     |     >> container I prepare (see the blog / sanitizers write-up I linked<br>
|     to) as<br>
|     |     I<br>
|     |     >> realized that we had a Rcpp Gallery post similar to what that as<><br>
|     |     >> conversion<br>
|     |     >> does.<br>
|     |     >><br>
|     |     >> And no issue with that code.<br>
|     |     >><br>
|     |     >> From a brief look at your package it seems like you are pushing<br>
|     the<br>
|     |     >> envelope<br>
|     |     >> a lot harder with fields and list of sparse matrices ( in<br>
|     dpmix.cpp,<br>
|     |     where<br>
|     |     >> another ASAN log pointed to ) so you may have to debug around<br>
|     there.<br>
|     |     >><br>
|     |     >> A small reproducible example would surely help us. So far I don't<br>
|     have<br>
|     |     one<br>
|     |     >> for as<sp_mat>.<br>
|     |     >><br>
|     |     >> Dirk<br>
|     |     >><br>
|     |     >> --<br>
|     |     >> <a href="http://dirk.eddelbuettel.com" target="_blank">http://dirk.eddelbuettel.com</a> | @eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a><br>
|     |     ><br>
|     |     ><br>
|     |     ><br>
|     |     ><br>
|     |     > --<br>
|     |     > Thank you, Terrance Savitsky<br>
|     |     ><br>
|     |     > _______________________________________________<br>
|     |     > Rcpp-devel mailing list<br>
|     |     > <a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>
|     |     > <a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/</a><br>
|     rcpp-devel<br>
|     |<br>
|     |<br>
|     |<br>
|     |<br>
|     | --<br>
|     | Thank you, Terrance Savitsky<br>
|<br>
|     --<br>
|     <a href="http://dirk.eddelbuettel.com" target="_blank">http://dirk.eddelbuettel.com</a> | @eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a><br>
|<br>
|<br>
|<br>
|<br>
| --<br>
| Thank you, Terrance Savitsky<br>
<br>
--<br>
<a href="http://dirk.eddelbuettel.com" target="_blank">http://dirk.eddelbuettel.com</a> | @eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Thank you, Terrance Savitsky
</div>