Warnings about out-of-bounds values, void memset, deprecated functions, etc. but no error when rebuilding cmdstan from cmdstanr on Windows

Issue

I just updated R, RTools, and RStudio to their most recent versions alongside reinstalling rstan, cmdstan, cmdrstan and brms. I’m seeing all sorts of warnings in my RStudio console while (a) installing cmdstan after already installing cmdstanr and (b) fitting a model in brms with the cmdstanr backend. Previously, I was able to fit this same model with no warnings, then I received an error that mingw32-make.exe could not be found and reinstalled everything once more, and now nearly half of my console is filled with red text and warnings during installation even though the packages install. Some of these warnings appear when fitting models in brms with the cmdrstanr backend as well, although the models produce sensible outputs…

Should I be concerned about this? I’m running Windows 10 with 12 cores and > 100 GB of RAM with a model that usually produces ~ 2GB output. Relevant version info and examples below:

  • R version: 4.2.1
  • cmdstanr_0.5.3
  • CmdStan 2.30.1
  • RTools 42
  • brms 2.17.0

Example During cmdstan Installation

Here’s what I do to install CmdStan(R):

# Install cmdstanr
install.packages(
"cmdstanr",  repos = c("https://mc-stan.org/r-packages/", getOption("repos")))

# Install cmdstan
library(cmdstanr)
check_cmdstan_toolchain(fix = TRUE, quiet = FALSE)
#> The C++ toolchain required for CmdStan is setup properly!
install_cmdstan(cores = 10, overwrite = TRUE,check_toolchain = FALSE,
                dir = "C:/Program Files/R")

During installation, the first warning I see is found on the last line below:

 Latest CmdStan release is v2.30.1
* Installing CmdStan v2.30.1 in C:/Program Files/R/cmdstan-2.30.1
* Downloading cmdstan-2.30.1.tar.gz from GitHub...
* Download complete
* Unpacking archive...
* Building CmdStan binaries...
INFO: Could not find files for the given pattern(s).

Occasionally I see some red lines, not sure if they’re warnings or just notifications. It does seem like there might be a namespace issue with ar being in both brms and stats but I can’t tell.

# Example 1:
#> ar: creating stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_kinsol.a

# Example 2:
#> ar: creating stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_cvodes.a

# Example 3:
#> C:/Program Files/R/cmdstan-2.30.1/stan/lib/stan_math/lib/tbb_2020.3/build/Makefile.tbb:28: CONFIG: cfg=release arch=intel64 compiler=gcc target=windows runtime=mingw12.1.0

Eventually I hit this part:

C:/Program Files/R/cmdstan/cmdstan-2.30.1/stan/lib/stan_math/lib/tbb_2020.3/build/Makefile.tbb:28: CONFIG: cfg=release arch=intel64 compiler=gcc target=windows runtime=mingw12.1.0

I then get some VERY long red text with warning messages about deprecated binary_function or unary_function a little lower:

In file included from stan/lib/stan_math/lib/boost_1.78.0/boost/multi_array/multi_array_ref.hpp:32,
                 from stan/lib/stan_math/lib/boost_1.78.0/boost/multi_array.hpp:34,
                 from stan/lib/stan_math/lib/boost_1.78.0/boost/numeric/odeint/algebra/multi_array_algebra.hpp:22,
                 from stan/lib/stan_math/lib/boost_1.78.0/boost/numeric/odeint.hpp:63,
                 from stan/lib/stan_math/stan/math/prim/functor/ode_rk45.hpp:9,
                 from stan/lib/stan_math/stan/math/prim/functor/integrate_ode_rk45.hpp:6,
                 from stan/lib/stan_math/stan/math/prim/functor.hpp:14,
                 from stan/lib/stan_math/stan/math/prim.hpp:15,
                 from stan/src/stan/io/stan_csv_reader.hpp:5,
                 from stan/src/stan/mcmc/chains.hpp:4,
                 from src/cmdstan/stansummary_helper.hpp:4,
                 from src/cmdstan/print.cpp:2:
stan/lib/stan_math/lib/boost_1.78.0/boost/functional.hpp:180:45: warning: 'template<class _Arg, class _Result> struct std::unary_function' is deprecated [-Wdeprecated-declarations]
  180 |         : public boost::functional::detail::unary_function<typename unary_traits<Predicate>::argument_type,bool>
stan/lib/stan_math/lib/boost_1.78.0/boost/functional.hpp:214:45: warning: 'template<class _Arg1, class _Arg2, class _Result> struct std::binary_function' is deprecated [-Wdeprecated-declarations]
  214 |         : public boost::functional::detail::binary_function<
      |                                             ^~~~~~~~~~~~~~~
C:/rtools42/ucrt64/include/c++/12.1.0/bits/stl_function.h:131:12: note: declared here
  131 |     struct binary_function
      |            ^~~~~~~~~~~~~~~
stan/lib/stan_math/lib/boost_1.78.0/boost/functional.hpp:252:45: warning: 'template<class _Arg, class _Result> struct std::unary_function' is deprecated [-Wdeprecated-declarations]
  252 |         : public boost::functional::detail::unary_function<
      |                                             ^~~~~~~~~~~~~~
C:/rtools42/ucrt64/include/c++/12.1.0/bits/stl_function.h:117:12: note: declared here
  117 |     struct unary_function
      |            ^~~~~~~~~~~~~~
stan/lib/stan_math/lib/boost_1.78.0/boost/functional.hpp:299:45: warning: 'template<class _Arg, class _Result> struct std::unary_function' is deprecated [-Wdeprecated-declarations]
  299 |         : public boost::functional::detail::unary_function<

Right after that I get warnings about void memset:

In file included from ../tbb_2020.3/src/tbb/concurrent_hash_map.cpp:17:
../tbb_2020.3/include/tbb/concurrent_hash_map.h: In constructor 'tbb::interface5::internal::hash_map_base::hash_map_base()':
../tbb_2020.3/include/tbb/concurrent_hash_map.h:131:24: warning: 'void* memset(void*, int, size_t)' clearing an object of type 'struct tbb::interface5::internal::hash_map_base::bucket' with no trivial copy-assignment; use value-initialization instead [-Wclass-memaccess]

Which is followed by “value computed is not used” warning:

../tbb_2020.3/src/tbb/dynamic_link.cpp: In function 'void tbb::internal::dynamic_unlink(dynamic_link_handle)':
../tbb_2020.3/src/tbb/dynamic_link.cpp:33:39: warning: value computed is not used [-Wunused-value]
   33 |     #define dlclose( handle )       ( ! FreeLibrary( handle ) )
      |                                     ~~^~~~~~~~~~~~~~~~~~~~~~~~~
../tbb_2020.3/src/tbb/dynamic_link.cpp:418:13: note: in expansion of macro 'dlclose'
  418 |             dlclose( handle );
      |             ^~~~~~~

And then an array subscript being out of bounds warning:

C:/rtools42/ucrt64/include/psdk_inc/intrin-impl.h:838:1: warning: array subscript 0 is outside array bounds of 'long long unsigned int [0]' [-Warray-bounds]
  838 | __buildreadseg(__readgsqword, unsigned __int64, "gs", "q")
      | ^~~~~~~~~~~~~~
In function 'long long unsigned int __readgsqword(long unsigned int)',
    inlined from '_TEB* NtCurrentTeb()' at C:/rtools42/ucrt64/include/winnt.h:9612:86,
    inlined from 'void tbb::internal::generic_scheduler::init_stack_info()' at ../tbb_2020.3/src/tbb/scheduler.cpp:169:42,
    inlined from 'static tbb::internal::generic_scheduler* tbb::internal::generic_scheduler::create_master(tbb::internal::arena*)' at ../tbb_2020.3/src/tbb/scheduler.cpp:1302:23:
C:/rtools42/ucrt64/include/psdk_inc/intrin-impl.h:838:1: warning: array subscript 0 is outside array bounds of 'long long unsigned int [0]' [-Warray-bounds]
  838 | __buildreadseg(__readgsqword, unsigned __int64, "gs", "q")
      | ^~~~~~~~~~~~~~

The last unique warning is about different sizes:

task.o: duplicate section `.rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]' has different size
arena.o: duplicate section `.rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]' has different size
scheduler.o: duplicate section `.rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]' has different size

But at the end, it finishes with the following:

  #> * Finished installing CmdStan to C:/Program Files/R/cmdstan-2.30.1
  #> CmdStan path set to: C:/Program Files/R/cmdstan-2.30.1

NOTE: installation also says “Please add C:/Program Files/R/cmdstan/cmdstan-2.30.1/stan/lib/stan_math/lib/tbb to your PATH variable.” I added this (confirmed with stringr::str_split(Sys.getenv("PATH"), ";")) and nothing changes.

Example during model-fitting

So I’m fitting a hierarchical model in brms with the following options.

cores = 4,
chains = 4,
iter = 10000,
seed = 6,
backend = "cmdstanr",
threads = threading(3)

I get the deprecated unary and binary function warnings, but also some MASSIVE chunks of warning:

stan/lib/stan_math/stan/math/rev/functor/reduce_sum.hpp: In instantiation of ‘stan::math::internal::reduce_sum_impl<ReduceFunction, typename std::enable_if<stan::is_var<typename std::decay<Tp2>::type>::value, void>::type, ReturnType, Vec, Args …>::recursive_reducer::recursive_reducer(stan::math::internal::reduce_sum_impl<ReduceFunction, typename std::enable_if<stan::is_var<typename std::decay<Tp2>::type>::value, void>::type, ReturnType, Vec, Args …>::recursive_reducer&, tbb::split) [with ReduceFunction = model_22086d87eaedfcf553df6edff87d7ec2_model_namespace::partial_log_lik_lpmf_rsfunctor; ReturnType = stan::math::var_value; Vec = const std::vector&; Args = {const Eigen::Map<Eigen::Matrix<double, -1, 1, 0, -1, 1>, 0, Eigen::Stride<0, 0> >&, const Eigen::Map<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 0, Eigen::Stride<0, 0> >&, Eigen::Matrix<stan::math::var_value<double, void>, -1, 1, 0, -1, 1>&, stan::math::var_value<double, void>&, stan::math::var_value<double, void>&, stan::math::var_value<double, void>&, const std::vector<int, std::allocator >&, const Eigen::Map<Eigen::Matrix<double, -1, 1, 0, -1, 1>, 0, Eigen::Stride<0, 0> >&, Eigen::Matrix<stan::math::var_value<double, void>, -1, 1, 0, -1, 1>&}]’:
stan/lib/stan_math/lib/tbb_2020.3/include/tbb/parallel_reduce.h:186:27: required from ‘tbb::task* tbb::interface9::internal::start_reduce<Range, Body, Partitioner>::execute() [with Range = tbb::blocked_range; Body = stan::math::internal::reduce_sum_impl<model_22086d87eaedfcf553df6edff87d7ec2_model_namespace::partial_log_lik_lpmf_rsfunctor__, void, stan::math::var_value, const std::vector&, const Eigen::Map<Eigen::Matrix<double, -1, 1, 0, -1, 1>, 0, Eigen::Stride<0, 0> >&, const Eigen::Map<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 0, Eigen::Stride<0, 0> >&, Eigen::Matrix<stan::math::var_value<double, void>, -1, 1, 0, -1, 1>&, stan::math::var_value<double, void>&, stan::math::var_value<double,
void>&, stan::math::var_value<double, void>&, const std::vector<int, std::allocator >&, const Eigen::Map<Eigen::Matrix<double, -1, 1, 0, -1, 1>, 0, Eigen::Stride<0, 0> >&, Eigen::Matrix<stan::math::var_value<double, void>, -1, 1, 0, -1, 1>&>::recursive_reducer; Partitioner = const tbb::auto_partitioner]’
stan/lib/stan_math/lib/tbb_2020.3/include/tbb/parallel_reduce.h:181:11: required from here
stan/lib/stan_math/stan/math/rev/functor/reduce_sum.hpp:58:23: warning: ‘stan::math::internal::reduce_sum_impl<model_22086d87eaedfcf553df6edff87d7ec2_model_namespace::partial_log_lik_lpmf_rsfunctor__, void, stan::math::var_value, const std::vector&, const Eigen::Map<Eigen::Matrix<double, -1, 1, 0, -1, 1>, 0, Eigen::Stride<0, 0> >&, const Eigen::Map<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 0, Eigen::Stride<0, 0> >&, Eigen::Matrix<stan::math::var_value<double, void>, -1, 1, 0, -1, 1>&, stan::math::var_value<double, void>&, stan::math::var_value<double, void>&, stan::math::var_value<double, void>&, const std::vector<int, std::allocator >&, const Eigen::Map<Eigen::Matrix<double, -1, 1, 0, -1, 1>, 0, Eigen::Stride<0, 0> >&, Eigen::Matrix<stan::math::var_value<double, void>, -1, 1, 0, -1, 1>&>::recursive_reducer::local_args_tuple_scope_’ will be initialized after [-Wreorder]
58 | scoped_args_tuple local_args_tuple_scope_;
| ^~~~~~~~~~~~~~~~~~~~~~~

stan/lib/stan_math/stan/math/rev/functor/reduce_sum.hpp:57:25: warning: ‘std::tuple<const Eigen::Map<Eigen::Matrix<double, -1, 1, 0, -1, 1>, 0, Eigen::Stride<0, 0> >&, const Eigen::Map<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 0, Eigen::Stride<0, 0> >&, Eigen::Matrix<stan::math::var_value<double, void>, -1, 1, 0, -1, 1>&, stan::math::var_value<double, void>&, stan::math::var_value<double, void>&, stan::math::var_value<double, void>&, const std::vector<int, std::allocator >&, const Eigen::Map<Eigen::Matrix<double, -1, 1, 0, -1, 1>, 0, Eigen::Stride<0, 0> >&, Eigen::Matrix<stan::math::var_value<double, void>, -1, 1, 0, -1, 1>&> stan::math::internal::reduce_sum_impl<model_22086d87eaedfcf553df6edff87d7ec2_model_namespace::partial_log_lik_lpmf_rsfunctor__, void, stan::math::var_value, const std::vector&, const Eigen::Map<Eigen::Matrix<double, -1, 1, 0, -1, 1>, 0, Eigen::Stride<0, 0> >&, const Eigen::Map<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 0, Eigen::Stride<0, 0> >&, Eigen::Matrix<stan::math::var_value<double, void>, -1, 1, 0, -1, 1>&, stan::math::var_value<double, void>&, stan::math::var_value<double, void>&, stan::math::var_value<double, void>&, const std::vector<int, std::allocator >&, const Eigen::Map<Eigen::Matrix<double, -1, 1, 0, -1, 1>, 0, Eigen::Stride<0, 0> >&, Eigen::Matrix<stan::math::var_value<double, void>, -1, 1, 0, -1, 1>&>::recursive_reducer::args_tuple_’ [-Wreorder]
57 | std::tuple<Args…> args_tuple_;
| ^~~~~~~~~~~
stan/lib/stan_math/stan/math/rev/functor/reduce_sum.hpp:78:5: warning: when initialized here [-Wreorder]
78 | recursive_reducer(recursive_reducer& other, tbb::split)
| ^~~~~~~~~~~~~~~~~

1 Like