Skip to content

Fix/redirect exception handler output 2 #3951

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

Conversation

martin-cs
Copy link
Collaborator

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

This is #3921 redone to use messaget as suggested by @tautschnig plus the corresponding updates to the Java tools as #3897 . It fixes and enables the tests in #3902 . This should reduce the risk of output, especially exceptions, winding up on std::cerr when using JSON or XML output.

: parse_options_baset(JANALYZER_OPTIONS, argc, argv),
messaget(ui_message_handler),
: messaget(ui_message_handler),
parse_options_baset(JANALYZER_OPTIONS, argc, argv, *this),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and everywhere else: what about only passing the message handler, not the full messaget? I think that would reduce the amount of churn in this commit, and would still achieve the same effect.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do...

// messaget and then parse_options_base run before those of message_handlert.
// This means that the messaget object has a reference to a
// an uninitialised object. Using it here will likely cause a
// hard to debug failure somewhere in the messaget code.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would all that actually be pretty safe if we were using the message_handlert instead of the messaget? There arguably still is a risk that the message handler is not properly configured just yet and output would not end up formatted as desired, but it should be safe.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message_handlert won't be because it is a member variable. This is an issue with the current "inherit from messaget" approach.

@@ -37,7 +51,7 @@ void parse_options_baset::help()

void parse_options_baset::usage_error()
{
std::cerr << "Usage error!\n\n";
log.error() << "Usage error!\n\n";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that needs a << messaget::eom

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@tautschnig
Copy link
Collaborator

clang complains:

goto_diff_parse_options.cpp:64:26: error: base class 'parse_options_baset' is uninitialized when used here to access 'parse_options_baset::cmdline

@peterschrammel, any chance to get #3683 reviewed and approved? @martin-cs can surely fix things here, but that should just make the problem go away I think.

martin added 5 commits January 25, 2019 19:15
Getting parse_option_baset to use the same messaget object as
the rest of the application should mean that error message,
especially those from default exception handlers will be formatted
correctly.  So, if you use --json-ui then the exception messages
will be in JSON rather than just dumped on std::cerr.

There is an issue with object constructors; messaget should be
constructed before parse_option_baset so this patch swaps the
order of inheritance and thus construction.  However as the
message_handlert is a local variable, it's not actually safe to
use messaget during construction.  A comment explaining this
problem is given and the issue is no worse than it already was.
These should check that exception messages are output
wrapped in JSON rather than just dumped on std::cerr.
This is a copy of an earlier patch to the CBMC tools which replaced
patchy and inconsistent exception handling in each tool with the
comprehensive set of catch handlers in parse_options_baset.
@martin-cs martin-cs force-pushed the fix/redirect-exception-handler-output-2 branch from 3e83f00 to 6663119 Compare January 25, 2019 19:15
@martin-cs
Copy link
Collaborator Author

Third time lucky maybe : #3952 ?

@martin-cs martin-cs closed this Jan 25, 2019
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

Successfully merging this pull request may close these issues.

2 participants