david-cortes / isotree

(Python, R, C/C++) Isolation Forest and variations such as SCiForest and EIF, with some additions (outlier detection + similarity + NA imputation)
https://isotree.readthedocs.io
BSD 2-Clause "Simplified" License
192 stars 38 forks source link

Valgrind warning in CRAN checks #6

Closed david-cortes closed 4 years ago

david-cortes commented 4 years ago

The automatic checks from CRAN are detecting an issue when running the examples with Valgrind: https://www.stats.ox.ac.uk/pub/bdr/memtests/valgrind/isotree/isotree-Ex.Rout

The issue happens when calling R’s saveRDS, and the complaint is about un-initialized bytes that were allocated in the model object, which at that point only lives as a C++ object accessed through the external pointer system (Rcpp::Xptr). Oddly, no warning is given when the object is used all throughout the model fitting function.

Tried posting a message in the package development mailing lists, but so far no hints of what could be wrong: https://stat.ethz.ch/pipermail/r-package-devel/2020q3/005721.html

The CRAN maintainers would like to see this issue fixed before uploading a new version (the same warning comes in when trying version 0.1.16), but I have no clue of what went wrong there or how to fix. Am not able to reproduce the valgrind warning in my local machine either.

Any help is appreciated.

david-cortes commented 4 years ago

Seems to have been an issue with std::vector::emplace_back not doing value-initialization when the structs have a constructor as Struct() {}, which was now changed to Struct() = default and stopped the complaints in CRAN servers.