[Rcpp-devel] AddressSanitizer: stack-use-after-scope Error

Dirk Eddelbuettel edd at debian.org
Mon Nov 16 19:27:14 CET 2020


Hi Noah,

Thanks for posting here.  We'll try to help.

On 15 November 2020 at 18:30, Noah Greifer wrote:
| In searching for solutions to the problem of being able to check whether
| the issue in my package remains, I came across this
| <http://dirk.eddelbuettel.com/code/sanitizers.html> article posted by Dirk
| ("sanitizers: Testing R packages for ASAN and UBSAN errors"). It seems like
| this article is about using sanitizers, which helps you figure out if your
| build of R is able to detect the memory allocation errors I was facing, but
| doesn't give clear instructions on how to set up R to do this. As someone
| for whom using Rcpp was my first use of programming outside R, the
| instructions given in the article and in section 4.3 of Writing R
| Extensions are completely foreign to me and seem to require a deep
| knowledge of C++.

[ Not quite: `sanitizers` is a package I wrote when facing such ASAN/UBSAN
  report issues. I noticed that I at times had the additional difficulty of
  being unable to reproduce such errors when they should have reproduced -- so
  `sanitizers` "merely" regroups some of those errors to ensure the testing
  procedure you use, these days mostly Docker containers or RHub services,
  triggers them correctly and hence validates your setup. No more, really. ]

| I'm wondering if someone can provide me with a clear procedure on how to
| check if the memory allocation problem still remains in my package. Thank
| you.

This is is indeed advanced stuff, and sadly the CRAN maintainers sometimes
fling it at us. As Kevin said, the best bet really is to distill it into as
small an example as you can.  That is, in essence, what sanitizers does too
if you look at its sources.  Once you have a small example, it usually
becaome feasible / easier to find the solution to _not_ triggering the
report.  Many of us have found that this is often an underlying programming
bug in our packages, so as painful as it is when CRAN sticks the finger into
these sores they usually do need fixing.

Dirk

-- 
https://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list