Thanks for answering.

I’m not able to reproduce the warning when trying R CMD check with
valgrind on my computer (tried compiling with gcc9 and clang9), nor
with the r-debug docker images from github (
https://github.com/wch/r-debug). However, from what I was told when
trying to upload a new version of the package, the warning still
persist in the CRAN servers when checking the newer version.

About the source code: it actually complains about line
fit_model.cpp:751 :
hplane_root->reserve(exp_nodes);

Which is part of the struct ‘ModelOutputsExt *model_outputs’ (the one
that gets serialized through Cereal into an R raw vector, later
serialized through ‘saveRDS’).

The same std::vector in the struct is heavily used all throughout the
module, and in most cases it’s only used with std::vector::back and
std::vector::emplace_back (first emplace right after L751), so it’s
unlikely that it could have uninitialized elements with no complaints
from asan or valgrind when creating the S3 object that goes to
‘saveRDS’.

Best regards,
David Cortes
On Wed, 2020-07-08 at 20:59 +0300, Ivan Krylov wrote:
> On Wed, 08 Jul 2020 19:23:41 +0300
> David Cortes <david.cortes.riv...@gmail.com> wrote:
> 
> > - The warning is about an un-initialized value allocated in a call
> > to
> > C++ std::vector::reserve, which is called on a C++ vector member of
> > the
> > struct in the external pointer.
> 
> I'm ready to admit that I didn't read the code well enough, but it
> seems to me that the vector resized on line 752 resides in
> std::vector<WorkerMemory> worker_memory allocated on lines 411-415 in
> int fit_iforest(...) and then disposed of by the end of the function.
> I
> don't see workspace.ix_arr being saved anywhere model_outputs(_ext).
> I
> think that workspace.ix_arr shouldn't even exist by the time the
> lines
> following isolation.forest(...) are executed.
> 
> Can you reproduce the warning on your own computer? It might be
> helpful
> to run R -d 'valgrind --vgdb-error=1 --vgdb-stop-at=startup', follow
> Valgrind's instructions to attach the debugger to it, type "continue"
> into gdb, then trigger the warning in R and use gdb to gather more
> information when Valgrind stops the process around the memory access
> it considers uninitialised.
>

______________________________________________
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

Reply via email to