Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print statements inside a model are buffered into a stringstream and only printed when log_prob returns #3233

Open
WardBrian opened this issue Oct 4, 2023 · 0 comments

Comments

@WardBrian
Copy link
Member

Summary:

In situations like stan-dev/cmdstan#1207, where there is an infinite loop which never exits, a user may try to debug-by-print the loop condition. This will never be useful, as the infinite loop prevents the code from exiting and actually logging to the user.

Relevant code:

std::stringstream ss;
try {
stan::math::gradient(model_functional<M>(model, &ss), x, f, grad_f);
} catch (std::exception& e) {
if (ss.str().length() > 0)
logger.info(ss);
throw;
}
if (ss.str().length() > 0)
logger.info(ss);
}

Current Version:

v2.33.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant