Misaligned address sanitizer errors with `csr_matrix_times_vector()` - leading to CRAN package failing additional tests
Summary:
Sparse matrix arithmetic using csr_matrix_times_vector() seems to trigger sanitizer "misaligned address" errors.
Description:
My package multinma that fits models using rstan has been flagged as failing additional tests in gcc-UBSAN. Closer inspection seems to point to csr_matrix_times_vector() as the cause.
I have also opened a thread on discourse.
Reproducible Steps:
This small model recreates the sanitizer errors:
library(rstan)
mod <- "
data {
int n;
matrix[n, n] M;
}
transformed data {
int nz = num_elements(csr_extract_w(M));
vector[nz] Mw = csr_extract_w(M);
array[nz] int Mv = csr_extract_v(M);
array[n + 1] int Mu = csr_extract_u(M);
}
parameters {
vector[n] x;
}
transformed parameters {
vector[n] y = csr_matrix_times_vector(n, n, Mw, Mv, Mu, x);
}
model {
x ~ std_normal();
}
"
stan(model_code = mod,
data = list(
n = 2,
M = matrix(c(1, 0.5, 0.5, 1), nrow = 2, ncol = 2)
),
test_grad = TRUE)
Commenting out the transformed parameter removes the sanitizer warnings, so this seems to be a problem with csr_matrix_times_vector().
Current Output:
Details
TESTING GRADIENT FOR MODEL 'anon_model' NOW (CHAIN 1).
/usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/Core/CoreEvaluators.h:852:18: runtime error: reference binding to misaligned address 0x5556fef3455c for type 'struct Scalar', which requires 8 byte alignment
0x5556fef3455c: note: pointer points here
04 00 00 00 00 00 00 00 b0 1b a4 f9 56 55 00 00 20 4b 9e f9 56 55 00 00 b8 da 9f f9 56 55 00 00
^
/usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/Core/AssignEvaluator.h:637:26: runtime error: reference binding to misaligned address 0x5556fef3455c for type 'struct var_value', which requires 8 byte alignment
0x5556fef3455c: note: pointer points here
04 00 00 00 00 00 00 00 b0 1b a4 f9 56 55 00 00 20 4b 9e f9 56 55 00 00 b8 da 9f f9 56 55 00 00
^
/usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/Core/functors/AssignmentFunctors.h:24:100: runtime error: store to misaligned address 0x5556fef3455c for type 'struct var_value', which requires 8 byte alignment
0x5556fef3455c: note: pointer points here
04 00 00 00 00 00 00 00 b0 1b a4 f9 56 55 00 00 20 4b 9e f9 56 55 00 00 b8 da 9f f9 56 55 00 00
^
/usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/Core/CoreEvaluators.h:840:18: runtime error: reference binding to misaligned address 0x5556fef3455c for type 'const struct var_value', which requires 8 byte alignment
0x5556fef3455c: note: pointer points here
04 00 00 00 d0 40 f3 fe 56 55 00 00 e8 40 f3 fe 56 55 00 00 56 55 00 00 b8 da 9f f9 56 55 00 00
^
/usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/Core/CoreEvaluators.h:549:21: runtime error: reference binding to misaligned address 0x5556fef3455c for type 'const struct var_value', which requires 8 byte alignment
0x5556fef3455c: note: pointer points here
04 00 00 00 d0 40 f3 fe 56 55 00 00 e8 40 f3 fe 56 55 00 00 56 55 00 00 b8 da 9f f9 56 55 00 00
^
/usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/fun/value_of.hpp:25: runtime error: member access within misaligned address 0x5556fef3455c for type 'const struct var_value', which requires 8 byte alignment
0x5556fef3455c: note: pointer points here
04 00 00 00 d0 40 f3 fe 56 55 00 00 e8 40 f3 fe 56 55 00 00 56 55 00 00 b8 da 9f f9 56 55 00 00
^
/usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/fun/value_of.hpp:25: runtime error: member access within misaligned address 0x5556fef3455c for type 'const struct var_value', which requires 8 byte alignment
0x5556fef3455c: note: pointer points here
04 00 00 00 d0 40 f3 fe 56 55 00 00 e8 40 f3 fe 56 55 00 00 56 55 00 00 b8 da 9f f9 56 55 00 00
^
/usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/Core/CoreEvaluators.h:852:18: runtime error: reference binding to misaligned address 0x5556fef3457c for type 'struct Scalar', which requires 8 byte alignment
0x5556fef3457c: note: pointer points here
60 bd 9d f9 56 55 00 00 70 c0 9d f9 56 55 00 00 70 c0 9d f9 56 55 00 00 70 c0 9d f9 56 55 00 00
^
/usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/Core/AssignEvaluator.h:637:26: runtime error: reference binding to misaligned address 0x5556fef3457c for type 'struct var_value', which requires 8 byte alignment
0x5556fef3457c: note: pointer points here
60 bd 9d f9 56 55 00 00 70 c0 9d f9 56 55 00 00 70 c0 9d f9 56 55 00 00 70 c0 9d f9 56 55 00 00
^
/usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/core/var.hpp:82: runtime error: constructor call on misaligned address 0x5556fef3458c for type 'struct vari_type', which requires 8 byte alignment
0x5556fef3458c: note: pointer points here
70 c0 9d f9 56 55 00 00 70 c0 9d f9 56 55 00 00 70 c0 9d f9 56 55 00 00 70 c0 9d f9 56 55 00 00
^
/usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/core/vari.hpp:126: runtime error: member access within misaligned address 0x5556fef3458c for type 'struct vari_value', which requires 8 byte alignment
0x5556fef3458c: note: pointer points here
70 c0 9d f9 56 55 00 00 70 c0 9d f9 56 55 00 00 70 c0 9d f9 56 55 00 00 70 c0 9d f9 56 55 00 00
^
/usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/core/vari.hpp:126: runtime error: member access within misaligned address 0x5556fef3458c for type 'struct vari_value', which requires 8 byte alignment
0x5556fef3458c: note: pointer points here
70 c0 9d f9 00 00 00 00 00 00 00 00 56 55 00 00 70 c0 9d f9 56 55 00 00 70 c0 9d f9 56 55 00 00
^
/usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/core/vari.hpp:126: runtime error: constructor call on misaligned address 0x5556fef3458c for type 'struct vari_base', which requires 8 byte alignment
0x5556fef3458c: note: pointer points here
70 c0 9d f9 00 00 00 00 00 00 00 00 56 55 00 00 70 c0 9d f9 56 55 00 00 70 c0 9d f9 56 55 00 00
^
/usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/core/vari.hpp:28: runtime error: member access within misaligned address 0x5556fef3458c for type 'struct vari_base', which requires 8 byte alignment
0x5556fef3458c: note: pointer points here
70 c0 9d f9 00 00 00 00 00 00 00 00 56 55 00 00 70 c0 9d f9 56 55 00 00 70 c0 9d f9 56 55 00 00
^
/usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/core/vari.hpp:126: runtime error: member access within misaligned address 0x5556fef3458c for type 'struct vari_value', which requires 8 byte alignment
0x5556fef3458c: note: pointer points here
70 c0 9d f9 b0 3f 14 7c 5d 7f 00 00 56 55 00 00 70 c0 9d f9 56 55 00 00 70 c0 9d f9 56 55 00 00
^
/usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/core/vari.hpp:126: runtime error: member access within misaligned address 0x5556fef3458c for type 'struct vari_value', which requires 8 byte alignment
0x5556fef3458c: note: pointer points here
70 c0 9d f9 d0 3f 14 7c 5d 7f 00 00 56 55 00 00 70 c0 9d f9 56 55 00 00 70 c0 9d f9 56 55 00 00
^
/usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/core/vari.hpp:126: runtime error: member access within misaligned address 0x5556fef3458c for type 'struct vari_value', which requires 8 byte alignment
0x5556fef3458c: note: pointer points here
70 c0 9d f9 d0 3f 14 7c 5d 7f 00 00 27 1c f4 c8 b8 b8 ea 3f 56 55 00 00 70 c0 9d f9 56 55 00 00
^
/usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/core/vari.hpp:130: runtime error: member access within misaligned address 0x5556fef3458c for type 'struct vari_value', which requires 8 byte alignment
0x5556fef3458c: note: pointer points here
70 c0 9d f9 d0 3f 14 7c 5d 7f 00 00 27 1c f4 c8 b8 b8 ea 3f 00 00 00 00 00 00 00 00 56 55 00 00
^
/usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/Core/functors/AssignmentFunctors.h:24:100: runtime error: store to misaligned address 0x5556fef3457c for type 'struct var_value', which requires 8 byte alignment
0x5556fef3457c: note: pointer points here
60 bd 9d f9 56 55 00 00 70 c0 9d f9 56 55 00 00 70 c0 9d f9 d0 3f 14 7c 5d 7f 00 00 27 1c f4 c8
^
/usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/Core/CoreEvaluators.h:840:18: runtime error: reference binding to misaligned address 0x5556fef3457c for type 'const struct var_value', which requires 8 byte alignment
0x5556fef3457c: note: pointer points here
60 bd 9d f9 8c 45 f3 fe 56 55 00 00 a4 45 f3 fe 56 55 00 00 d0 3f 14 7c 5d 7f 00 00 27 1c f4 c8
^
/usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/Core/AssignEvaluator.h:637:26: runtime error: reference binding to misaligned address 0x5556fef3457c for type 'const struct var_value', which requires 8 byte alignment
0x5556fef3457c: note: pointer points here
60 bd 9d f9 8c 45 f3 fe 56 55 00 00 a4 45 f3 fe 56 55 00 00 d0 3f 14 7c 5d 7f 00 00 27 1c f4 c8
^
/usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/Core/functors/AssignmentFunctors.h:24:100: runtime error: load of misaligned address 0x5556fef3457c for type 'const struct var_value', which requires 8 byte alignment
0x5556fef3457c: note: pointer points here
60 bd 9d f9 8c 45 f3 fe 56 55 00 00 a4 45 f3 fe 56 55 00 00 d0 3f 14 7c 5d 7f 00 00 27 1c f4 c8
^
/usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/Core/CoreEvaluators.h:834:18: runtime error: reference binding to misaligned address 0x5556fef3457c for type 'const struct var_value', which requires 8 byte alignment
0x5556fef3457c: note: pointer points here
60 bd 9d f9 8c 45 f3 fe 56 55 00 00 a4 45 f3 fe 56 55 00 00 d0 3f 14 7c 5d 7f 00 00 27 1c f4 c8
^
/usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/Core/CoreEvaluators.h:774:21: runtime error: reference binding to misaligned address 0x5556fef3457c for type 'const struct var_value', which requires 8 byte alignment
0x5556fef3457c: note: pointer points here
60 bd 9d f9 8c 45 f3 fe 56 55 00 00 a4 45 f3 fe 56 55 00 00 d0 3f 14 7c 5d 7f 00 00 27 1c f4 c8
^
/usr/local/lib/R/site-library/StanHeaders/include/stan/math/prim/eigen_plugins.h:160:41: runtime error: member access within misaligned address 0x5556fef3457c for type 'const struct var_value', which requires 8 byte alignment
0x5556fef3457c: note: pointer points here
60 bd 9d f9 8c 45 f3 fe 56 55 00 00 a4 45 f3 fe 56 55 00 00 d0 3f 14 7c 5d 7f 00 00 27 1c f4 c8
^
/usr/local/lib/R/site-library/StanHeaders/include/stan/math/prim/eigen_plugins.h:160:46: runtime error: member access within misaligned address 0x5556fef3458c for type 'struct vari_type', which requires 8 byte alignment
0x5556fef3458c: note: pointer points here
56 55 00 00 d0 3f 14 7c 5d 7f 00 00 27 1c f4 c8 b8 b8 ea 3f 00 00 00 00 00 00 00 00 d0 3f 14 7c
^
/usr/local/lib/R/site-library/StanHeaders/include/stan/math/prim/eigen_plugins.h:160:46: runtime error: reference binding to misaligned address 0x5556fef3459c for type 'const double', which requires 8 byte alignment
0x5556fef3459c: note: pointer points here
b8 b8 ea 3f 00 00 00 00 00 00 00 00 d0 3f 14 7c 5d 7f 00 00 40 bf c4 63 46 6c 9d bf 00 00 00 00
^
/usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/Core/CoreEvaluators.h:774:47: runtime error: reference binding to misaligned address 0x5556fef3459c for type 'const double', which requires 8 byte alignment
0x5556fef3459c: note: pointer points here
b8 b8 ea 3f 00 00 00 00 00 00 00 00 d0 3f 14 7c 5d 7f 00 00 40 bf c4 63 46 6c 9d bf 00 00 00 00
^
/usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/Core/DenseCoeffsBase.h:100:67: runtime error: reference binding to misaligned address 0x5556fef3459c for type 'const double', which requires 8 byte alignment
0x5556fef3459c: note: pointer points here
^
/usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/SparseCore/SparseDenseProduct.h:100:96: runtime error: load of misaligned address 0x5556fef3459c for type 'const double', which requires 8 byte alignment
0x5556fef3459c: note: pointer points here
b8 b8 ea 3f 00 00 00 00 00 00 00 00 d0 3f 14 7c 5d 7f 00 00 40 bf c4 63 46 6c 9d bf 00 00 00 00
^
/usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/Core/CoreEvaluators.h:852:18: runtime error: reference binding to misaligned address 0x5556fef3455c for type 'struct Scalar', which requires 8 byte alignment
0x5556fef3455c: note: pointer points here
04 00 00 00 d0 40 f3 fe 56 55 00 00 e8 40 f3 fe 56 55 00 00 56 55 00 00 b8 da 9f f9 56 55 00 00
^
/usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/Core/CoreEvaluators.h:792:21: runtime error: reference binding to misaligned address 0x5556fef3455c for type 'struct var_value', which requires 8 byte alignment
0x5556fef3455c: note: pointer points here
04 00 00 00 d0 40 f3 fe 56 55 00 00 e8 40 f3 fe 56 55 00 00 56 55 00 00 b8 da 9f f9 56 55 00 00
^
/usr/local/lib/R/site-library/StanHeaders/include/stan/math/prim/eigen_plugins.h:160:41: runtime error: member access within misaligned address 0x5556fef3455c for type 'struct var_value', which requires 8 byte alignment
0x5556fef3455c: note: pointer points here
04 00 00 00 d0 40 f3 fe 56 55 00 00 e8 40 f3 fe 56 55 00 00 56 55 00 00 b8 da 9f f9 56 55 00 00
^
TESTING GRADIENT FOR MODEL 'anon_model' NOW (CHAIN 2).
TESTING GRADIENT FOR MODEL 'anon_model' NOW (CHAIN 3).
TESTING GRADIENT FOR MODEL 'anon_model' NOW (CHAIN 4).
RStan Version:
> packageVersion("rstan")
[1] ‘2.32.5’
R Version:
Issue recreated using the rocker/r-devel-san docker container, which builds r-devel with compiler sanitizers.
> R.version.string
[1] "R Under development (unstable) (2024-01-22 r85820)"
Operating System:
Linux run in rocker/r-devel-san docker container. Issue first appeared on CRAN gcc-UBSAN test environment (also a flavour of linux).
I believe I have found the source of this in the Stan Math library. This function allocates u onto our autodiff stack, but in because u is of length 3 in this case, and sizeof(int) == 4, the autodiff stack pointer is moved forward 12 bytes. The next allocation is then not aligned to a multiple of 8
Aha! That might explain why I could make the sanitizer error disappear by adding/removing certain rows of data but not others. When the data structure results in M having nz non-zero entries so that nz * 4 is a multiple of 8 I don't get the error. But when nz * 4 is not a multiple of 8 I do get the error.
I'm guessing any fix will take a little while to make it to CRAN, if it's an issue all the way upstream in Stan Math? I have until 2024-02-08 to resolve the error before I'm threatened with removal of my package, but I'll try to argue the case for retaining my package whilst this is fixed upstream.
Thank you so much for looking into this!
Hopefully the fix is small enough that the RStan team can backport it sooner
@bgoodri I think it should be safe to cherry-pick the changes from https://github.com/stan-dev/math/pull/3014/ back to earlier versions to resolve this for rstan
I'll try the backport
Thanks both. CRAN didn't respond to my emails and have now just archived multinma, which is rather frustrating.
Any news on if/when the backport is likely to be possible? If not I might submit an update to CRAN that temporarily avoids running the affected tests, it's not ideal but better than remaining archived.
Happy to help in any way I can; I could run the sanitizer checks on a release candidate if that would be useful? Thanks again 🙂
I also got an e-mail from CRAN warning that geostan will be taken down if not fixed by feb 29 2024. It has an installation error and a note about gcc-UBSAN.
I haven't had a chance to look closely yet but the installation error is coming after a matrix-vector product, so presumably this is connected to the same issue as @dmphillippo.
https://cran.r-project.org/web/checks/check_results_geostan.html
/home/hornik/tmp/R.check/r-release-gcc/Work/build/Packages/RcppEigen/include/Eigen/src/Core/products/SelfadjointMatrixVector.h:39:24: note: by argument 4 of type ‘const double*’ to ‘static void Eigen::internal::selfadjoint_matrix_vector_product<Scalar, Index, StorageOrder, UpLo, ConjugateLhs, ConjugateRhs, Version>::run(Index, const Scalar*, Index, const Scalar*, Scalar*, Scalar) [with Scalar = double; Index = long int; int StorageOrder = 0; int UpLo = 1; bool ConjugateLhs = false; bool ConjugateRhs = false; int Version = 0]’ declared here
39 | EIGEN_DONT_INLINE void selfadjoint_matrix_vector_product<Scalar,Index,StorageOrder,UpLo,ConjugateLhs,ConjugateRhs,Version>::run(
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[1]: *** [/home/hornik/tmp/R.check/r-release-gcc/Work/build/etc/Makeconf:196: stanExports_foundation.o] Terminated
@ConnorDonegan your CRAN note calls out csr_matrix_times_vector in the back trace so I'd say it is almost certainly the same issue.
Okay, and I see the changes here https://github.com/stan-dev/math/pull/3014 have already been merged into the development branch, thanks @WardBrian. I have a couple weeks before geostan gets removed from CRAN, should I expect to see the changes released before then?
I am going to backport this and the max / min thing and push another StanHeaders to CRAN.
On Thu, Feb 15, 2024 at 12:23 PM Brian Ward @.***> wrote:
@ConnorDonegan https://github.com/ConnorDonegan your CRAN note calls out csr_matrix_times_vector in the back trace so I'd say it is almost certainly the same issue.
— Reply to this email directly, view it on GitHub https://github.com/stan-dev/rstan/issues/1111#issuecomment-1946666894, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZ2XKUQ2BDGMGKBHWBTRVTYTZAATAVCNFSM6AAAAABCL7YR46VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNBWGY3DMOBZGQ . You are receiving this because you were mentioned.Message ID: @.***>
Yes
On Thu, Feb 15, 2024 at 12:47 PM Connor Donegan @.***> wrote:
Okay, and I see the changes here stan-dev/math#3014 https://github.com/stan-dev/math/pull/3014 have already been merged into the development branch, thanks @WardBrian https://github.com/WardBrian. I have a couple weeks before geostan gets removed from CRAN, should I expect to see the changes released before then?
— Reply to this email directly, view it on GitHub https://github.com/stan-dev/rstan/issues/1111#issuecomment-1946744992, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZ2XKQCLXQHYJIMJR77LP3YTZCZPAVCNFSM6AAAAABCL7YR46VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNBWG42DIOJZGI . You are receiving this because you were mentioned.Message ID: @.***>
I see StanHeaders 2.32.6 is up on CRAN now, I take it this contains the backported fix?
Yes, and the min/max thing.
I notice that the multinma and geostan packages have install errors now on CRAN, listed as of 2024-04-04 23:03:26 CEST (...just now)
This looks like the same issue again:
/home/hornik/tmp/R.check/r-release-gcc/Work/build/Packages/RcppEigen/include/Eigen/src/Core/products/SelfadjointMatrixVector.h:41:6: note: by argument 4 of type ‘const double*’ to ‘static void Eigen::internal::selfadjoint_matrix_vector_product<Scalar, Index, StorageOrder, UpLo, ConjugateLhs, ConjugateRhs, Version>::run(Index, const Scalar*, Index, const Scalar*, Scalar*, Scalar) [with Scalar = double; Index = long int; int StorageOrder = 0; int UpLo = 1; bool ConjugateLhs = false; bool ConjugateRhs = false; int Version = 0]’ declared here 41 | void selfadjoint_matrix_vector_product<Scalar,Index,StorageOrder,UpLo,ConjugateLhs,ConjugateRhs,Version>::run( | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ make[1]: *** [/home/hornik/tmp/R.check/r-release-gcc/Work/build/etc/Makeconf:196: stanExports_foundation.o] Terminated
https://cloud.r-project.org/web/checks/check_results_geostan.html
https://cran.r-project.org/web/checks/check_results_multinma.html
I am not sure that it is the same error as the alignment thing in the OP (that was fixed). The geostan and multinma packages look like they might just be timing out on the CRAN server builds.
The reason I thought it may be connected to this issue is that they're both terminating on matrix vector products again
multinma:
/home/hornik/tmp/R.check/r-patched-gcc/Work/build/Packages/RcppEigen/include/Eigen/src/Core/products/TriangularMatrixVector.h:105:24**: note: by argument 5 of type ‘const double*’ to ‘static void Eigen::internal::triangular_matrix_vector_product<Index, Mode, LhsScalar, ConjLhs, RhsScalar, ConjRhs, 1, Version>::run(Index, Index, const LhsScalar*, Index, const RhsScalar*, Index, ResScalar*, Index, const ResScalar&) [with Index = long int; int Mode = 6; LhsScalar = double; bool ConjLhs = false; RhsScalar = double; bool ConjRhs = false; int Version = 0]’ declared here 105 | EIGEN_DONT_INLINE void triangular_matrix_vector_product<Index,Mode,LhsScalar,ConjLhs,RhsScalar,ConjRhs,RowMajor,Version> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ make[1]: *** [/home/hornik/tmp/R.check/r-patched-gcc/Work/build/etc/Makeconf:200: stanExports_survival_mspline.o] Terminated
The original issue was about a runtime error, this seems to be different
multinma is now failing again the UBSAN tests on CRAN, with what looks like the same issue: https://www.stats.ox.ac.uk/pub/bdr/memtests/gcc-UBSAN/multinma/tests/testthat.Rout
Installing the latest StanHeaders 2.32.7, the small reprex in the first post recreates the errors in rocker/r-devel-san.
Downgrading to StanHeaders 2.32.6 doesn't give the UBSAN errors.
Is it possible that the latest 2.32.7 StanHeaders missed including this patch?
I have been given until 2024-05-22 to have this fixed before multinma is archived again.
@dmphillippo yes, it appears that SH 2.32.7 is missing the patch to stan/math/rev/memory/stack_alloc.hpp
@bgoodri the changes to min/max (https://github.com/stan-dev/math/pull/3024) also look like they got dropped from 2.32.7
I'll fix it
Thanks @bgoodri! Any chance this will be patched on CRAN by 22nd? I appreciate it must take a while getting through all the revdep checks etc.
I see StanHeaders 2.32.8 is on CRAN now, but I'm still seeing the sanitizer errors with this version. I think that the stack_alloc patch may still be missing? The other min/max patch does seem to be in this version, from what I can tell. Sorry!
@bgoodri just to follow up on this, the multinma and geostan packages are now both archived from CRAN due to the sanitiser warnings. As far as I can tell StanHeaders 2.32.8 is still missing the patch from stan-dev/math#3014 that was added in 2.32.6 to fix this - @WardBrian may be able to confirm?
2.32.8's source code seems to be missing https://github.com/stan-dev/math/pull/3014, but does include https://github.com/stan-dev/math/pull/3024
@dmphillippo StanHeaders 2.32.9 on CRAN now has the padding fix.