Repository navigation
Function pointer removal: give candidate functions a source location - #9626
Draft
tautschnig wants to merge 1 commit into
Draft
tautschnig wants to merge 1 commit into
tautschnig wants to merge 1 commit into
Conversation
goto-instrument --remove-function-pointers and --value-set-fi-fp-removal
followed by cbmc failed with an invariant violation when cbmc added the C
library ("front-ends should construct symbol expressions with source
locations", casting_replace_symbol.cpp), as soon as one of the candidate
functions of a removed call is defined by the library, for example malloc
called through a function pointer.
Worst-case removal (remove_function_pointerst::remove_function_pointer,
also run by --value-set-fi-fp-removal for calls whose value set has no
function) builds the candidates as symbol_exprt{name, type}, without a
source location, and remove_function_pointer() uses them for the new call
and comparison. Linking the library replaces each use of a function the
library defines (finalize_linking), and casting_replace_symbolt requires
these symbol expressions to have a location. cbmc itself removes function
pointers only after adding the library, so it did not run into this.
Give each candidate the source location of the call it replaces, as the
front end does for a function designator, in remove_function_pointer(),
which all ways of removing function pointers use. This also makes the
locations of candidates found by the value-set analysis independent of
which use of the function the analysis recorded first.
Found on goto programs of libxml2, which calls malloc, realloc and free
through the function pointers xmlMalloc, xmlRealloc and xmlFree.
Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #9626 +/- ##
===========================================
+ Coverage 81.29% 81.34% +0.04%
===========================================
Files 1725 1727 +2
Lines 191680 191717 +37
Branches 73 73
===========================================
+ Hits 155835 155950 +115
+ Misses 35845 35767 -78 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
goto-instrument --remove-function-pointers and --value-set-fi-fp-removal followed by cbmc failed with an invariant violation when cbmc added the C library ("front-ends should construct symbol expressions with source locations", casting_replace_symbol.cpp), as soon as one of the candidate functions of a removed call is defined by the library, for example malloc called through a function pointer.
Worst-case removal (remove_function_pointerst::remove_function_pointer, also run by --value-set-fi-fp-removal for calls whose value set has no function) builds the candidates as symbol_exprt{name, type}, without a source location, and remove_function_pointer() uses them for the new call and comparison. Linking the library replaces each use of a function the library defines (finalize_linking), and casting_replace_symbolt requires these symbol expressions to have a location. cbmc itself removes function pointers only after adding the library, so it did not run into this.
Give each candidate the source location of the call it replaces, as the front end does for a function designator, in remove_function_pointer(), which all ways of removing function pointers use. This also makes the locations of candidates found by the value-set analysis independent of which use of the function the analysis recorded first.
Found on goto programs of libxml2, which calls malloc, realloc and free through the function pointers xmlMalloc, xmlRealloc and xmlFree.