stan-dev / stan

Stan development repository. The master branch contains the current release. The develop branch contains the latest stable development. See the Developer Process Wiki for details.
https://mc-stan.org
BSD 3-Clause "New" or "Revised" License
2.56k stars 366 forks source link

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

Open WardBrian opened 9 months ago

WardBrian commented 9 months ago

Summary:

In situations like https://github.com/stan-dev/cmdstan/issues/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: https://github.com/stan-dev/stan/blob/b22074b57e459132c160c02267566695a634ec54/src/stan/model/gradient.hpp#L25-L35

Current Version:

v2.33.0