[R-pkg-devel] Reproducing the clang-UBSAN test environment in rhub or somewhere else?
Peter Carbonetto
peter@c@rbonetto @end|ng |rom gm@||@com
Fri Nov 7 22:14:10 CET 2025
Thanks to all of you (Ivan, Ben, Tomas, Dirk) for your detailed and
informative suggestions, all of which have been deeply helpful, but it took
me some time to act on these suggestions since I am not well versed in
these tools and concepts. (Despite having developed several packages over
the years that use Rcpp and the accompanying packages—RcppArmadillo,
RcppParallel, etc—all of this is almost entirely new to me.)
Most urgently, I have a specific question based on Dirk's response:
The rocker images were indeed super helpful, and I think is getting me very
close to reproducing the original issues ("reference binding to null
pointer…"). I was able to (eventually) set up a r-devel-ubsan-clang
container on my MacBook Pro, install the fastTopics package, and run the
basic checks using "R CMD check …". (I will share the steps I took since I
figured it might be useful for others trying to reproduce the clang-UBSAN
environment.)
However, I was not able to reproduce the exact errors Dirk obtained by
running the R code purl'ed from the single_cell_rnaseq_basic.Rmd vignette.
I thought that this might work:
R -d valgrind --vanilla < single_cell_rnaseq_basic.R
but this did not produce any of the "runtime errors" such as:
/usr/local/lib/R/site-library/RcppArmadillo/include/current/armadillo_bits/Mat_meat.hpp:7043:26:
runtime error: reference binding to null pointer of type 'const double'
Dirk, could you please share the exact R or Rscript command you ran to
obtain these errors? In addition, do I need to install fastTopics and the
other R packages in a specific way as well? That is, are there special
flags (perhaps existing somewhere in
https://www.stats.ox.ac.uk/pub/bdr/memtests/README.txt) that are needed to
activate these extra debugging checks?
Thanks again,
Peter
On Mon, Nov 3, 2025 at 11:27 AM Dirk Eddelbuettel <edd using debian.org> wrote:
>
> Peter,
>
> Besides the comments Tomas already made, consider looking more closely at
> the
> vignettes. The error in [0] indicates that this comes from vignettes, not
> examples or tests.
>
> I have been providing Docker containers for gcc and clang ASAN/UBSAN for
> what
> must be close to a decade. These often work as they try to follow the setup
> used by BDR on his machines. [1] When they fail the very useful 'sumo'
> container by Winston often referenced here in threads can also be useful.
>
> So as a test, I pulled a refreshed version of the rocker/r-devel-san
> container [2] and installed the (considerable) dependency set of your
> packages. As expected, nothing in tests or examples. I then purl'ed the
> code
> out of the vignettes and ran those, and that seems to replicate the issue:
>
> ../../src/tbbmalloc/backref.cpp:150:21: runtime error: index 1 out of
> bounds for type 'BackRefBlock *[1]'
> Fitting rank-6 Poisson NMF to 100 x 16791 sparse matrix.
> Running at most 20 SCD updates, without extrapolation (fastTopics 0.7-30).
> /usr/local/lib/R/site-library/RcppArmadillo/include/current/armadillo_bits/Mat_meat.hpp:7043:26:
> runtime error: reference binding to null pointer of type 'const double'
> /usr/local/lib/R/site-library/RcppArmadillo/include/current/armadillo_bits/access.hpp:26:100:
> runtime error: reference binding to null pointer of type 'double'
> /usr/local/lib/R/site-library/RcppArmadillo/include/current/armadillo_bits/Mat_meat.hpp:7043:26:
> runtime error: reference binding to null pointer of type 'const double'
> /usr/local/lib/R/site-library/RcppArmadillo/include/current/armadillo_bits/access.hpp:26:100:
> runtime error: reference binding to null pointer of type 'double'
> /usr/local/lib/R/site-library/RcppArmadillo/include/current/armadillo_bits/subview_meat.hpp:1420:54:
> runtime error: reference binding to null pointer of type 'const double'
> /usr/local/lib/R/site-library/RcppArmadillo/include/current/armadillo_bits/access.hpp:26:100:
> runtime error: reference binding to null pointer of type 'double'
>
> This could be an upstream issue is Armadillo as wrapped in RcppArmadillo. I
> as maintainer need to balance the (frequent) updates upstream with the CRAN
> Policy of "no more than six releases in six month" so I have sat out the
> bug
> fix release 15.0.3 as well as the new releases 15.2 and 15.2.1 and not
> uploaded them to CRAN. However, they are packaged at my master branch and
> available via R-universe.
>
> So as a test I fetched 15.2.1 from there, installed it, re-installed your
> package and ran the test again. The errors persist suggesting it may be
> your
> code and it creates matrices or matrix views. (Needless to say, the error
> could of course also be on our end in RcppArmadillo.)
>
> Would it be possible to simplify the code down to a simpler, self-contained
> matrix example not requiring all the packages? That would also make
> testing
> with the other container quicker as we would not have to reinstall all
> those
> dependencies.
>
> Another possibility is parallelism as the message comes from tbbmalloc so
> maybe trying in serial mode may help?
>
> Lastly, as you asked about rhub: I am not involved with rhub and do not use
> it much myself so I cannot help much on that aspect. But if this does not
> replicate under their container you should be able to hook up the one used
> here, i.e. rocker/r-devel-san (as well as the other one) under GitHub
> Actions
> as they let you pull in other Docker containers (when running under Linux).
>
> It's too nice outside right now here in Chicagoland so I'll now disappear
> for
> a bit on my bike but we can possibly pick this up later.
>
> Cheers, Dirk
>
> [0]
> https://www.stats.ox.ac.uk/pub/bdr/memtests/clang-UBSAN/fastTopics/build_vignettes.log
> [1] In a more ideal world, his tests could be based on containers and these
> containers could be provided. Alas, on this planet we're not there yet.
> [2] Both containers are refreshed regularly via schedule GitHub Actions.
> --
> dirk.eddelbuettel.com | @eddelbuettel | edd using debian.org
>
[[alternative HTML version deleted]]
More information about the R-package-devel
mailing list