make_negative_definite_and_solve divides by fabs(eigenvalues[i]) without checking for zeros (division at line 24). For a parameter absent from the target, the Hessian is zero and the step is 0/0:
// model whose log_prob ignores its single parameter, returns 0.5
stan::optimization::newton_step<flat_model, false>(model, params_r, params_i);
// f0 = 0.5, params_r[0] = -nan
The caller loop accepts NaN (while (f1 < f0) is false for NaN) and the service returns error_codes::OK without a finiteness check, so the run reports success with NaN parameters. Probably related to #3306.
Environment:
- Ubuntu 22.04.5 LTS (WSL2, kernel 6.18.33.2-microsoft-standard-WSL2), x86_64
- stan-dev/stan develop @ 8ad5c98 (stan::math develop @ d20b238b9c)
- g++ 11.4.0 (Ubuntu 22.04), -std=c++17
make_negative_definite_and_solvedivides byfabs(eigenvalues[i])without checking for zeros (division at line 24). For a parameter absent from the target, the Hessian is zero and the step is0/0:The caller loop accepts NaN (
while (f1 < f0)is false for NaN) and the service returnserror_codes::OKwithout a finiteness check, so the run reports success with NaN parameters. Probably related to #3306.Environment: