Default constructor to system_functor leaves raw pointer uninitialized (UB if read)
Open
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 839
- Forks
- 220
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 14
Description
Description:
InSTAN_MATH_REV_MAT_FUNCTOR_ALGEBRA_SYSTEM_HPP, we have:
struct system_functor {
F f_;
Eigen::Matrix<T0, Eigen::Dynamic, 1> x_;
Eigen::Matrix<T1, Eigen::Dynamic, 1> y_;
std::vector<double> dat_;
std::vector<int> dat_int_;
std::ostream* msgs_;
system_functor() {}
system_functor(const F& f, const Eigen::Matrix<T0, Eigen::Dynamic, 1>& x,
const Eigen::Matrix<T1, Eigen::Dynamic, 1>& y,
const std::vector<double>& dat,
const std::vector<int>& dat_int, std::ostream* msgs)
: f_(f), x_(x), y_(y), dat_(dat), dat_int_(dat_int), msgs_(msgs) {}
It seems like the default constructor should initialize msgs_ to nullptr to avoid msgs_ being some random value in the best case? This is UB if the pointer is either read or dereferenced.
Current Version:
v2.17.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open STAN_MATH_REV_MAT_FUNCTOR_ALGEBRA_SYSTEM_HPP and inspect the default constructor of system_functor. Ensure msgs_ has a defined null state when that constructor is used, then run the relevant existing test suite or build checks to confirm the change does not break compilation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100