Skip to content

Stop generating nondet pointees for function pointers #4940

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
merged 2 commits into from
Feb 4, 2020

Conversation

xbauch
Copy link
Contributor

@xbauch xbauch commented Jul 23, 2019

when building the entry point. Because that leads to declaring function-type
objects and then assigning values to them. Rather we should simply initialise
the function pointer with NONDET(fptr_type) and let the function-pointer removal
find the candidates.

  • 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.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

✔️
Passed Diffblue compatibility checks (cbmc commit: e5d5c9f).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/120202139

@codecov-io
Copy link

codecov-io commented Jul 23, 2019

Codecov Report

Merging #4940 into develop will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #4940   +/-   ##
========================================
  Coverage    67.38%   67.38%           
========================================
  Files         1157     1157           
  Lines        95096    95096           
========================================
  Hits         64080    64080           
  Misses       31016    31016
Flag Coverage Δ
#cproversmt2 42.66% <100%> (ø) ⬆️
#regression 63.89% <100%> (ø) ⬆️
#unit 31.92% <0%> (ø) ⬆️
Impacted Files Coverage Δ
src/ansi-c/c_nondet_symbol_factory.cpp 100% <100%> (ø) ⬆️

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 077b5ee...68c9554. Read the comment docs.

@xbauch xbauch force-pushed the fix/function-pointer-init branch 2 times, most recently from a0308a5 to 68c9554 Compare January 17, 2020 14:49
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

✔️
Passed Diffblue compatibility checks (cbmc commit: 68c9554).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/144957668

Copy link
Contributor

Choose a reason for hiding this comment

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

This comes up a lot, maybe we should have a utility function like is_pointer_to_object or something of the sort?

Copy link
Contributor

@thk123 thk123 left a comment

Choose a reason for hiding this comment

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

🚫 Please add a test for when there is a function of the right type, to check it is selected. And two functions of the right type, to check it picks between them (as I believe the new behaviour should / old behaviour did not).

@@ -48,7 +48,7 @@ void symbol_factoryt::gen_nondet_init(
return;
}

if(type.id()==ID_pointer)
if(type.id() == ID_pointer && to_pointer_type(type).subtype().id() != ID_code)
Copy link
Contributor

Choose a reason for hiding this comment

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

❓ What happens with pointers to code then? Just random number?
Read the PR description - that is worth a comment here explaining why we don't need to initialize it here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now the symbol is explicitly assigned a nondet (of the function-ptr type).

@xbauch xbauch force-pushed the fix/function-pointer-init branch from 68c9554 to 9ea6857 Compare January 29, 2020 13:16
@xbauch
Copy link
Contributor Author

xbauch commented Jan 29, 2020

Please add a test for when there is a function of the right type, to check it is selected. And two functions of the right type, to check it picks between them (as I believe the new behaviour should / old behaviour did not).

I've added the tests. Note that existing functions will only be considered as candidates if dereferenced somewhere in the code.

when building the entry point. Because that leads to declaring function-type
objects and then assigning values to them. Rather we should simply initialise
the function pointer with NONDET(fptr_type) and let the function-pointer removal
find the candidates.
@xbauch xbauch force-pushed the fix/function-pointer-init branch from 9ea6857 to 1299a54 Compare January 29, 2020 13:22
Copy link
Contributor

@thk123 thk123 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the extra tests.
This just needs code owner approval @tautschnig @kroening

@thk123
Copy link
Contributor

thk123 commented Jan 29, 2020

currently failing CI, but looks transient, have restarted the job

@thk123
Copy link
Contributor

thk123 commented Jan 30, 2020

This is now passing CI and just needs code owner approval @tautschnig @kroening

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.

8 participants