[R-pkg-devel] Help package checks using valgrind

Merlise Clyde, Ph.D. clyde at duke.edu
Tue May 23 23:40:03 CEST 2017

I am trying to resolve the Additional Issues reported by CRAN @ https://www.stats.ox.ac.uk/pub/bdr/memtests/valgrind/BAS-Ex.Rout for my package BAS which calls C and Fortran.

The output from the above URL is not particularly informative (at least to me) for identifying where the problems are in the source code, as there are  missing file names and line numbers as seen in this snippet from the above url:

> cleanEx()
==9861== Conditional jump or move depends on uninitialised value(s)
==9861==    at 0x403DBF3: ???
==9861==    by 0x1A694397: ???
==9861==    by 0x1A694397: ???
==9861==    by 0x1A6943B3: ???
==9861==    by 0xFFEFF861F: ???
==9861==  Uninitialised value was created by a heap allocation
==9861==    at 0x4C2BBAD: malloc (/builddir/build/BUILD/valgrind-3.11.0/coregrind/m_replacemalloc/vg_replace_malloc.c:299)
==9861==    by 0x4E5AFE: GetNewPage (svn/R-devel/src/main/memory.c:875)
==9861==    by 0x4E77AF: Rf_allocVector3 (svn/R-devel/src/main/memory.c:2651)
==9861==    by 0x4E79A8: Rf_allocVector (svn/R-devel/src/include/Rinlinedfuns.h:196)
==9861==    by 0x4E79A8: R_alloc (svn/R-devel/src/main/memory.c:2160)
==9861==    by 0x540C52: logicalSubscript (svn/R-devel/src/main/subscript.c:563)
==9861==    by 0x5437BE: realSubscript (svn/R-devel/src/main/subscript.c:723)
==9861==    by 0x5437BE: Rf_makeSubscript (svn/R-devel/src/main/subscript.c:980)
==9861==    by 0x5455AB: VectorSubset (svn/R-devel/src/main/subset.c:188)
==9861==    by 0x5455AB: do_subset_dflt (svn/R-devel/src/main/subset.c:826)
==9861==    by 0x4A8539: VECSUBSET_PTR (svn/R-devel/src/main/eval.c:5179)
==9861==    by 0x4A8539: bcEval (svn/R-devel/src/main/eval.c:6618)
==9861==    by 0x4B685F: Rf_eval (svn/R-devel/src/main/eval.c:624)
==9861==    by 0x4B894E: R_execClosure (svn/R-devel/src/main/eval.c:1614)
==9861==    by 0x4EA827: dispatchMethod (svn/R-devel/src/main/objects.c:335)
==9861==    by 0x4EAC12: Rf_usemethod (svn/R-devel/src/main/objects.c:375)

To see if I could replicate locally and debug, I have built R 3.4.0 with valgrind-3.11.0 on FC 23  using the configuration options

./configure --with-valgrind-instrumentation=2 --with-system-valgrind-headers=yes CFLAGS='-g -O0' FCFLAGS='-g -O0’

My package is built also using -g and -O0 for debugging and turning off optimization.

Running  valgrind on the output from examples/vignettes from R CMD check

R -d "valgrind --tool=memcheck --leak-check=full --track-origins=yes" --vanilla < BAS.Rcheck/BAS-Ex.R

produces similar output as from CRAN -  i.e. no line numbers to code  (I have also tried travis-CI which indicates no problems and  R-devel under docker  which also replicates the non informative messages of CRAN :-)  so clearly missing something to produce the line numbers.


1) Are these problems with libraries outside of my code  or fortran  and I can ask CRAN to ignore? How can I tell if these are problems with system libraries (i.e. configuration on my system, but also those for CRAN) rather than my package code?

2) Any suggestions for other configuration options (system, R, package. valgrind) that would provide more informative output?
    (for Fedora or any other platforms using docker)

3) Any alternative methods recommended for tracking this down instead of using valgrind?


> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Fedora 23 (Twenty Three)

Matrix products: default
BLAS: /usr/local/lib64/R/lib/libRblas.so
LAPACK: /usr/local/lib64/R/lib/libRlapack.so

source code is at http://github.com/merliseclyde/BAS

Merlise A Clyde
Professor & Chair Department of Statistical Science
Duke University

clyde at duke.edu<mailto:clyde at duke.edu>

	[[alternative HTML version deleted]]

More information about the R-package-devel mailing list