Discussion:
[Rcpp-devel] UBSAN warning
Timothy
2018-06-30 19:56:29 UTC
Permalink
Hi,

I maintain a package on CRAN. Recently I posted an update and was asked
about UBSAN warning produced during checks of the previous version:
https://www.stats.ox.ac.uk/pub/bdr/memtests/clang-UBSAN/kernelboot/tests/testthat.Rout
It is not clear for me where does the warning come from, could you give me
some hints what could it be? The warning message seems to relate to Rcpp
itself, isn't it? If not, what is the best way of diagnosing causes of such
warnings?

Thanks in advance,
Timothy
Jan van der Laan
2018-07-02 14:40:06 UTC
Permalink
Judging from the name of the object in which the error occurs, I suspect
it is in a line in which you compare a R-vector with a single (double)
value.

The error is in the function

inline int rhs_is_not_na(int i) const {
STORAGE x = lhs[i] ;
return Rcpp::traits::is_na<RTYPE>(x) ? x : op( x, rhs ) ;
}

This functions seems to return the left hand side of the operator, when
the left hand value is NA. Guess this could result in the message you
see when the left hand value is a double.

Looking at your code I see

if (bandwidth < 0.0)
Rcpp::stop("bandwidth needs to be non-negative");

if (!R_FINITE(bandwidth))
Rcpp::stop("inappropriate value of bandwidth");


in
https://github.com/twolodzko/kernelboot/blob/master/src/univar-kd.cpp. I
would make more sense to first test for NA and then for < 0.0.

HTH,
Jan
Post by Timothy
Hi,
I maintain a package on CRAN. Recently I posted an update and was asked
https://www.stats.ox.ac.uk/pub/bdr/memtests/clang-UBSAN/kernelboot/tests/testthat.Rout
It is not clear for me where does the warning come from, could you give
me some hints what could it be? The warning message seems to relate to
Rcpp itself, isn't it? If not, what is the best way of diagnosing causes
of such warnings?
Thanks in advance,
Timothy
_______________________________________________
Rcpp-devel mailing list
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Loading...