[R-pkg-devel] Getting started with memory debugging

Dirk Eddelbuettel edd @ending from debi@n@org
Mon Jan 14 03:59:14 CET 2019


On 14 January 2019 at 09:48, Michael Chirico wrote:
| Hello all,
| 
| I'm getting started doing some debugging of memory errors and got stuck
| trying to reproduce the errors found during my CRAN submission process:
| 
| https://cran.r-project.org/web/checks/check_results_geohashTools.html
| 
| Starting with the clang-ASAN issues, my approach was to try and use the
| rocker/r-devel-san image.

Good idea! I once set this up for a similar need, and then created the
'sanitiziers' package to have a few "known to fail" test cases to make sure
the container was still valid and identifying faults it was supposed to find.

But being busy with a number of other things meant I did not keep up with
this container. So there is no promise it currently reflects what CRAN tests
for.

Winston built another (comprehensive !!) set of images over at this repo:
https://github.com/wch/r-debug

These are more current -- but fundamentally they have the same exact flaw:
CRAN does their thing, and someone has to catch up.  Deep down, that really
is a silly game.  We'd be (much) better off if the CRAN testbeds were truly
reproducible, and I had meant to write something up suggestion something
around that idea. It hasn't happened.

So here you are.
 
| Launching with the package directory mounted via:
| 
| docker run --rm -it -v
| /Users/michael.chirico/github/geohashTools/:/home/docker/geohashTools
| rocker/r-devel-san /bin/bash
| 
| Building required libraries:
| 
| apt-get update
| apt-get install libgdal-dev libudunits2-dev
| 
| Then installing my Imports/Suggests:
| 
| Rscript -e "install.packages(c('Rcpp', 'sp', 'sf', 'testthat', 'mockery'))"
| 
| Now attempting to reproduce the memory errors:
| 
| cd /home/docker/geohashTools
| RD CMD build .
| RD CMD check geohashTools_0.2.0.tar.gz
| 
| But this is check is successful (I was hoping it'd fail)... I assume the
| problem is from the last few steps. The manual says:
| 
| >
| > It requires code to have been compiled and linked with -fsanitize=address
| 
| But I'm not sure how to enforce this (I assumed it was being handled by how
| RD binary is built but I didn't notice any compilation output from R CMD
| build .

I am a little out of sync with your package here. Maybe it "merely" requires
that the library you reinstalled also rebuilds with -fsanitize=address which
you could ensure, I'd hope, via PKG_CPPFLAGS and/or editing of its src/Makevars.

Because that is essentially it: you do need *all* of

 - R itself
 - the package you wanted
 - and its dependencies

to be built consistently for SAN/ASAN with the very settings CRAN uses.

Which are "documented" in a README somewhere on some site.  I think it is
worthwhile having a conversation about how we can do one step better than
that. I would be happy to help, but a little constrained on free time and
cannot lead this. Can you, or someone else?

Dirk

| 
| Any help on getting started here would be appreciated :)
| Michael Chirico
| 
| PS the source can be found at https://github.com/MichaelChirico/geohashTools
| 
| 	[[alternative HTML version deleted]]
| 
| ______________________________________________
| R-package-devel using r-project.org mailing list
| https://stat.ethz.ch/mailman/listinfo/r-package-devel

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd using debian.org



More information about the R-package-devel mailing list