vegandevs / vegan

R package for community ecologists: popular ordination methods, ecological null models & diversity analysis
https://vegandevs.github.io/vegan/
GNU General Public License v2.0
448 stars 97 forks source link

Protection error in do_wcentre #653

Closed jarioksa closed 4 months ago

jarioksa commented 4 months ago

CRAN checks for vegan_2.6-6 contains "additional issue" rchk:

Package vegan version 2.6-6
Package built using 86566/R 4.5.0; x86_64-pc-linux-gnu; 2024-05-20 16:03:08 UTC; unix   
Checked with rchk version fdc068715daa3a256062cc20e0d4a5157dacc9a4 LLVM version 14.0.6
More information at https://github.com/kalibera/cran-checks/blob/master/rchk/PROTECT.md
For rchk in docker image see https://github.com/kalibera/rchk/blob/master/doc/DOCKER.md

Function do_wcentre
  [UP] unprotected variable x while calling allocating function Rf_coerceVector vegan/src/goffactor.c:83
  [UP] unprotected variable x while calling allocating function Rf_duplicate vegan/src/goffactor.c:84
  [UP] unprotected variable x while calling allocating function Rf_allocMatrix vegan/src/goffactor.c:85

Here [UP] means unprotected SEXP pointer.

Protection error means that garbage collection can destroy the pointer before it is used, and this can segfault R (not only vegan). I may have seen this: reverse dependencies test sometimes fails with vectorfit in testing flowCHIC.

This also means that I need learn new skills and read a bit.

jarioksa commented 4 months ago

I think this is fixed in commit 33b4c3379ee (cherry-picked to 2.7-0 or master as 5f18b27a) and a bug-fix version 2.6-6.1 was submitted to CRAN. I checked the fix with Tomas Kalibera's Docker image (kalibera/rchk), but I'm waiting for CRAN team's confirmation.

jarioksa commented 4 months ago

The fix was blessed by the CRAN team, and vegan_2.6-6.1 is on the CRAN.