[R-pkg-devel] "Additional issues" show WRITE outside an array

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Fri Jul 26 13:44:39 CEST 2019


On Fri, 26 Jul 2019 01:50:36 -0500
Jiahuan ye <jiahuanye431 using gmail.com> wrote:

> I am very confused what causes the ERROR.

Your code on line 197 of src/min_wgss.cpp causes memory access outside
the block that had been allocated for the best_change_point vector.

I have not read the code in depth, but it looks like the length of
best_change_point should be M at this point. Array indices on the C++
side start with 0 and end at (length-1), so erasing the element at
position M in a NumericVector of length M in Rcpp code results in
undefined behaviour.

-- 
Best regards,
Ivan



More information about the R-package-devel mailing list