[R-pkg-devel] Valgrind warning on saveRDS, about object in external pointer

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Wed Jul 8 19:59:33 CEST 2020

On Wed, 08 Jul 2020 19:23:41 +0300
David Cortes <david.cortes.rivera using 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.

Best regards,

More information about the R-package-devel mailing list