Skip to content

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

Open

Description

@WardBrian

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions