[Rcpp-devel] Call to function through pointer to incorrect function type on UBSAN

Helske, Jouni jouni.helske at jyu.fi
Thu Jul 13 00:00:46 CEST 2017


Thanks Kevin,

I submitted bssm again to CRAN and claimed that the issue is with clang 4.0.0, but CRAN just updated to clang 4.0.1 and the issue remains (and there is also a new issue...).

But, while implementing new stuff which also use Xptr, I realized that I can somewhat streamline my previous codes, which I hope might result warning free code by accident. ;)

Best,

Jouni
________________________________
Lähettäjä: Kevin Ushey [kevinushey at gmail.com]
Lähetetty: 9. heinäkuuta 2017 2:33
Vastaanottaja: Helske, Jouni
Kopio: rcpp-devel at r-forge.wu-wien.ac.at
Aihe: Re: [Rcpp-devel] Call to function through pointer to incorrect function type on UBSAN

I can't replicate the reported UBSAN issues on my macOS machine (R-devel compiled with LLVM clang 4.0.1, with address + undefined behavior sanitizers active).

The warnings look somewhat dubious to me: for example, the first warning:

function_pointers.h:99:12: runtime error: call to function a1_fn(arma::Col<double> const&, arma::Col<double> const&) through pointer to incorrect function type 'arma::Col<double> (*)(const arma::Col<double> &, const arma::Col<double> &)'
/tmp/RtmpObvRHm/sourceCpp-x86_64-pc-linux-gnu-0.12.11/sourcecpp_96075e756157/growth_model_functions.cpp:7: note: a1_fn(arma::Col<double> const&, arma::Col<double> const&) defined here


If I'm reading that correctly, you have the following types:

Pointer:                      (arma::Col<double> const&,  arma::Col<double> const& )
Actual:  arma::Col<double> (*)(const arma::Col<double> &, const arma::Col<double> &)


and those look compatible to me (the only difference is the ordering of the 'const &' printing in each case).

Unless I'm missing something obvious, it seems like this might just be a bug in the version of UBSAN used on the CRAN build machines? The fact that this error is not seen with gcc, only with clang, supports that hypothesis, so I think you can safely ignore those errors. (Perhaps this was a bug in Clang 4.0.0 that was fixed in Clang 4.0.1)

Kevin


On Fri, Jul 7, 2017 at 2:58 PM, Helske, Jouni <jouni.helske at jyu.fi<mailto:jouni.helske at jyu.fi>> wrote:
I got some warnings on CRAN with UBSAN relating to my use of user supplied C++ function using Xptr: https://www.stats.ox.ac.uk/pub/bdr/memtests/clang-UBSAN/bssm/build_vignettes.log

I can't see anything wrong in my codes, although I have just tried to mimic some Dirk's Xptr examples without fully understanding what is going on, so maybe I actually do something silly. But I then noticed that Rcpp also has similar kind of warnings (https://www.stats.ox.ac.uk/pub/bdr/memtests/clang-UBSAN/Rcpp/build_vignettes.log), so I wonder if these are anything to worry about? I tested my package on GCC based address sanitizer using docker, and did not get any warnings with that setup, which makes me think that maybe it's just some clang issue? Some googling seems to support this theory: https://stackoverflow.com/questions/43220926/call-to-function-unknown-through-pointer-to-incorrect-function-type

Best,

Jouni




_______________________________________________
Rcpp-devel mailing list
Rcpp-devel at lists.r-forge.r-project.org<mailto:Rcpp-devel at lists.r-forge.r-project.org>
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20170712/8785ee8f/attachment.html>


More information about the Rcpp-devel mailing list