Skip to content

Function pointer restrictions: support labels in JSON input #6610

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

Merged

Conversation

tautschnig
Copy link
Collaborator

@tautschnig tautschnig commented Jan 25, 2022

This is a follow-up fix to 771a153, which added support for
labels as function-pointer identifiers. That commit, however, failed to
consider JSON input, and instead only resulted in support for
command-line specified restrictions.

Fixes: #6609

Please review commit-by-commit.

  • 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.
  • n/a 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).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@codecov
Copy link

codecov bot commented Jan 25, 2022

Codecov Report

Merging #6610 (73980e4) into develop (8aa6be8) will increase coverage by 0.01%.
The diff coverage is 90.10%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #6610      +/-   ##
===========================================
+ Coverage    76.62%   76.64%   +0.01%     
===========================================
  Files         1578     1578              
  Lines       181180   181210      +30     
===========================================
+ Hits        138833   138884      +51     
+ Misses       42347    42326      -21     
Impacted Files Coverage Δ
src/goto-programs/restrict_function_pointers.h 100.00% <ø> (ø)
src/util/config.h 57.14% <ø> (ø)
src/util/piped_process.cpp 81.48% <ø> (ø)
unit/util/piped_process.cpp 31.29% <ø> (ø)
...rc/solvers/smt2_incremental/smt_solver_process.cpp 68.57% <50.00%> (-7.30%) ⬇️
src/goto-programs/restrict_function_pointers.cpp 80.27% <89.58%> (+0.13%) ⬆️
src/ansi-c/ansi_c_entry_point.cpp 88.97% <100.00%> (+0.32%) ⬆️
.../goto-instrument/goto_instrument_parse_options.cpp 69.24% <100.00%> (-0.08%) ⬇️
src/util/config.cpp 57.85% <100.00%> (+0.36%) ⬆️
unit/goto-programs/restrict_function_pointers.cpp 100.00% <100.00%> (ø)
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5917ab4...73980e4. Read the comment docs.

Copy link
Contributor

@chrisr-diffblue chrisr-diffblue left a comment

Choose a reason for hiding this comment

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

Looks OK to me, with bonus points if there was a test case demonstrating the fix (my apologies if I missed one...), and double bonus points if there was a little extra comments - but nothing blocking.


restrict_function_pointers(
ui_message_handler, goto_model, function_pointer_restrictions);
restrict_function_pointers(ui_message_handler, goto_model, options);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice :-)

No changes in behaviour: this commit just moves the pointer-name parsing
introduced in 771a153 to a function of its own. This is to
prepare for a fix of diffblue#6609: the same name parsing also needs to be added
to function-pointer-restriction parsing from JSON files.

To enable this code move, the exception class is moved to the global
scope.
This is a follow-up fix to 771a153, which added support for
labels as function-pointer identifiers. That commit, however, failed to
consider JSON input, and instead only resulted in support for
command-line specified restrictions.

Fixes: diffblue#6609
Rather than requiring users to (necessarily!) make at least two calls,
just process what users actually have available (a goto model and some
command line options).
Copy link
Contributor

@chrisr-diffblue chrisr-diffblue left a comment

Choose a reason for hiding this comment

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

Thanks for the test case, and the extra commentary. Re-asserting my approval after those additions.

/// Parse \p candidate to distinguish whether it refers to a function pointer
/// symbol directly (as produced by \ref label_function_pointer_call_sites), or
/// a source location via its statement label. In the latter case, resolve the
/// name to the underlying function pointer symbol.
Copy link
Contributor

Choose a reason for hiding this comment

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

Brilliant, thanks :-)

@tedinski
Copy link

I can confirm this solves the problem we had using restrictions files with Kani (formerly RMC).

Copy link
Contributor

@NlightNFotis NlightNFotis left a comment

Choose a reason for hiding this comment

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

LGTM

@tautschnig tautschnig merged commit 60d3466 into diffblue:develop Feb 2, 2022
@tautschnig tautschnig deleted the bugfixes/6609-restrictions-json branch February 2, 2022 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Label-based function pointer restrictions fail for JSON file
6 participants