ocbe-uio / BayesMallows

R-package for Bayesian preference learning with the Mallows rank model.
https://ocbe-uio.github.io/BayesMallows/
GNU General Public License v3.0
21 stars 9 forks source link

Not too suprising... #353

Closed osorensen closed 7 months ago

osorensen commented 8 months ago

image

https://cran.r-project.org/web/checks/check_results_BayesMallows.html

I'm on it.

osorensen commented 8 months ago

First step in the right direction: I'm reproducing the error on rocker/r-devel-san.

image
osorensen commented 8 months ago

Here is where it happens!! Nothing really to do with the C++ code except for bad checking of input. I give it empty data.

https://github.com/ocbe-uio/BayesMallows/blob/5e59306b380fd23b6e7d2d66be44f6b15a40202a/tests/testthat/test-compute_mallows.R#L84-L89

osorensen commented 8 months ago

Result of running test_check("BayesMallows", reporter = LocationReporter).

Start test: compute_mallows is platform independent
  'test-compute_mallows.R:76:3' [success]
  'test-compute_mallows.R:81:3' [success]
End test: compute_mallows is platform independent

Start test: compute_mallows gives prior samples
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/subview_meat.hpp:1420:54: runtime error: reference binding to null pointer of type 'const unsigned int'
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/access.hpp:28:100: runtime error: reference binding to null pointer of type 'unsigned int'
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/subview_meat.hpp:1420:54: runtime error: reference binding to null pointer of type 'const unsigned int'
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/access.hpp:28:100: runtime error: reference binding to null pointer of type 'unsigned int'
  'test-compute_mallows.R:89:3' [success]
End test: compute_mallows gives prior samples

Start test: compute_observation_frequency works
  'test-compute_observation_frequency.R:2:3' [success]
  'test-compute_observation_frequency.R:11:3' [success]
  'test-compute_observation_frequency.R:15:3' [success]
End test: compute_observation_frequency works
osorensen commented 8 months ago

To complete the story. After constructing data with zero rows and setting n_assessors = 0, it goes here, samples an empty vector and then tries to add it to the first column of cluster_assignment.

https://github.com/ocbe-uio/BayesMallows/blob/5e59306b380fd23b6e7d2d66be44f6b15a40202a/src/clustering_class.cpp#L19-L20

osorensen commented 7 months ago
Thanks, we see with valgrind: > test_check("BayesMallows") ==63076== Conditional jump or move depends on uninitialised value(s) ==63076== at 0x5B9358: rsum (svn/R-devel/src/main/summary.c:165) ==63076== by 0x5BB2F0: do_summary (svn/R-devel/src/main/summary.c:860) ==63076== by 0x4FB957: R_forceAndCall (svn/R-devel/src/main/eval.c:2409) ==63076== by 0x42CC38: do_lapply (svn/R-devel/src/main/apply.c:75) ==63076== by 0x539AB9: do_internal (svn/R-devel/src/main/names.c:1409) ==63076== by 0x4DC880: bcEval (svn/R-devel/src/main/eval.c:7742) ==63076== by 0x4F67AF: Rf_eval (svn/R-devel/src/main/eval.c:1152) ==63076== by 0x4F8551: R_execClosure (svn/R-devel/src/main/eval.c:2360) ==63076== by 0x4F930D: applyClosure_core (svn/R-devel/src/main/eval.c:2248) ==63076== by 0x4F97E6: Rf_applyClosure (svn/R-devel/src/main/eval.c:2268) ==63076== by 0x4DD859: bcEval (svn/R-devel/src/main/eval.c:7693) ==63076== by 0x4F67AF: Rf_eval (svn/R-devel/src/main/eval.c:1152) ==63076== Uninitialised value was created by a heap allocation ==63076== at 0x484A83D: posix_memalign (/builddir/build/BUILD/valgrind-3.22.0/coregrind/m_replacemalloc/vg_replace_malloc.c:2099) ==63076== by 0x18CB3A81: acquire (R-devel/site-library/RcppArmadillo/include/armadillo_bits/memory.hpp:74) ==63076== by 0x18CB3A81: arma::Mat::init_warm(unsigned int, unsigned int) (R-devel/site-library/RcppArmadillo/include/armadillo_bits/Mat_meat.hpp:440) ==63076== by 0x18CBB104: set_size (R-devel/site-library/RcppArmadillo/include/armadillo_bits/Mat_meat.hpp:6828) ==63076== by 0x18CBB104: Clustering::Clustering(Parameters const&, Rcpp::Vector<19, Rcpp::PreserveStorage> const&, unsigned int) (test/BayesMallows.Rcheck/00_pkg_src/BayesMallows/src/clustering_class.cpp:23) ==63076== by 0x18CDF53B: run_mcmc(Rcpp::Vector<19, Rcpp::PreserveStorage>, Rcpp::Vector<19, Rcpp::PreserveStorage>, Rcpp::Vector<19, Rcpp::PreserveStorage>, Rcpp::Vector<19, Rcpp::PreserveStorage>, Rcpp::Vector<19, Rcpp::PreserveStorage>, Rcpp::Nullable >, Rcpp::Nullable >, bool) (test/BayesMallows.Rcheck/00_pkg_src/BayesMallows/src/run_mcmc.cpp:21) ==63076== by 0x18CA9BD5: _BayesMallows_run_mcmc (test/BayesMallows.Rcheck/00_pkg_src/BayesMallows/src/RcppExports.cpp:128) Please fix and resubmit. Best, Uwe Ligges