From edd at debian.org  Sun Jan 18 16:53:47 2015
From: edd at debian.org (Dirk Eddelbuettel)
Date: Sun, 18 Jan 2015 09:53:47 -0600
Subject: [Rd] [Resolved] (Was: Request for help with UBSAN and total absense
 of CRAN) response
In-Reply-To: <20150116152142.Horde.uxImQmEwhY5UuR52g4U0GfA@webmailnew.dds.nl>
References: <21685.14887.946988.975035@max.nulle.part>
	<20150116152142.Horde.uxImQmEwhY5UuR52g4U0GfA@webmailnew.dds.nl>
Message-ID: <21691.55051.421275.849136@max.nulle.part>


I would like to express my deepest gratitude to the CRAN Maintainers for
keeping up with their perfect record of never responding to questions from
mere mortals like myself. The ensuing utter and complete silence allowed me
to work with a much higher concentration level.

More seriously, I owe a big thank you to Martyn Plummer and Jan van der Laan
for replying here (and in off-list follow-ups), and to Jeff Horner who
offered help via Twitter and off-list emails.  Thanks to their help, I did
get to the bottom of this, and it seems that part of (either mine only, or a
more general) confusion was that I wanted the test to actually _abort_ on
error.  Which, as I found after too many failed tries, requires also setting
the -fno-sanitize-recover option as well.

Long story short, we now have a working "appliance" to test this via Docker.

This is building on some of the examples I showed at the end of my useR! 2014
presentation, the work Carl and I have been doing in the Rocker.org repo for
Docker containers for R, some experimentation, and an only-at-GitHub-yet new
script for littler.  I hope to blog about this in some more detail, but if
you have Docker set-up, pull the rocker/r-devel-ubsan-clang container.  

Then:

i)  to replicate the reported error:

    docker run --rm -ti -v $(pwd):/mnt rocker/r-devel-ubsan-clang \
           check.r --setwd /mnt --install-deps RcppAnnoy_0.0.5.tar.gz 

    which runs the container with 
      - post-run cleanup (--rm), 
      - terminal and interactive mode (-ti), 
      - the current directory mounted as /mnt in the container (-v ...),
      - invoking the check.r script (from littler as on GitHub, in the path in the
        container) with options to install package dependencies
      - the known-bad tarball

ii) to see a fix not triggering it

    docker run --rm -ti -v $(pwd):/mnt rocker/r-devel-ubsan-clang \
           check.r --setwd /mnt --install-deps RcppAnnoy_0.0.5.1.tar.gz 

    as above but using an updated tarball not showing the error.

This is generic: you can plug any of your R package tarballs in there
and it will run the test.  [ This assumes dependencies can be satisfied via
install.packages(); need to add a hook for apt-get as needed etc pp ]

The UBSAN config I settled on for now is close to what Martyn had sent me (in
off-list follow-up):

 CC="clang-3.5 -fsanitize=undefined \
      -fno-sanitize=float-divide-by-zero,vptr,function -fno-sanitize-recover" 
 CXX="clang++-3.5 -fsanitize=undefined \
      -fno-sanitize=float-divide-by-zero,vptr,function -fno-sanitize-recover"
 CXX1X="clang++-3.5 -fsanitize=undefined \
      -fno-sanitize=float-divide-by-zero,vptr,function -fno-sanitize-recover" 

We may want to turn on other options; Jeff Horner sent me his config which
has a lot more goodies enabled.  

I'd welcome follow-up by anyone interested in working on this, either by
(off-list) email or directly over at the GitHub repo for this container:
   https://github.com/rocker-org/r-devel-san-clang

Thanks,  Dirk

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



[Rd] [Resolved] (Was: Request for help with UBSAN and total absense of CRAN) response
Dirk Eddelbuettel