You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Difficulty using "assert(false)" for unimplemented functions #6393
If I use the arguments '--generate-function-body-options', 'assert-false', '--generate-function-body', '.*', I see the expected failure for missing functions, but also references to missing standard library functions, which was unexpected. Is there a better way to do this?
<builtin-library-memset> function memset
[memset.assertion.1] assertion false: FAILURE
If we use --add-library first with goto-instrument, this works as expected.
intmain() {
void*x=malloc(1); // should not be replaced by `assert(false);`assert(x!=0);
void*y=mallocx(1); // should be replaced by `assert(false);`assert(y!=0);
}
Also, rather than just throwing an assert false violation it would save a lot of debug effort if we got an error of the form "undefined function reached".
Also, rather than just throwing an assert false violation it would save a lot of debug effort if we got an error of the form "undefined function reached".
That sounds like a worthwhile improvement, but it is slightly off track from the original problem described in this issue. I have raised a task in my team's internal tracking system, to keep track of your suggestion.
It seems like Saswat has managed to find a way to make the functionality you wanted work for the moment. I think that ideally we should generate an appropriate warning/suggestion if an attempt is made to generate function bodies, before the standard libraries have been linked.
One could argue that this is a symptom of a more general issue, which is how to we ensure that folks run the steps of a transformation in the right order. We might want to look at annotating code with information about what has/has-not been done to it so we can check if further transformations are safe. There is an RFC started over on #6495 to discuss that.
Can we close this issue and pick up the discussion over there?
Just confirming that using --add-libraryin the samegoto-instrument call together with --generate-function-body works just fine and does exactly the right thing. I will nevertheless issue two follow-up PRs:
Cleanup of goto-instrument to make sure that --add-library works correctly with all code transformations.
Adjusting the comment for the assertion generated.
Activity
SaswatPadhi commentedon Oct 13, 2021
We tried this with
mallocand having#include <stdlib.h>doesn't help either.commandline:
SaswatPadhi commentedon Oct 13, 2021
If we use
--add-libraryfirst withgoto-instrument, this works as expected.commandline:
jimgrundy commentedon Oct 20, 2021
Also, rather than just throwing an assert false violation it would save a lot of debug effort if we got an error of the form "undefined function reached".
thomasspriggs commentedon Dec 3, 2021
That sounds like a worthwhile improvement, but it is slightly off track from the original problem described in this issue. I have raised a task in my team's internal tracking system, to keep track of your suggestion.
thomasspriggs commentedon Dec 3, 2021
It seems like Saswat has managed to find a way to make the functionality you wanted work for the moment. I think that ideally we should generate an appropriate warning/suggestion if an attempt is made to generate function bodies, before the standard libraries have been linked.
jimgrundy commentedon Dec 16, 2021
One could argue that this is a symptom of a more general issue, which is how to we ensure that folks run the steps of a transformation in the right order. We might want to look at annotating code with information about what has/has-not been done to it so we can check if further transformations are safe. There is an RFC started over on #6495 to discuss that.
Can we close this issue and pick up the discussion over there?
tautschnig commentedon May 31, 2022
Just confirming that using
--add-libraryin the samegoto-instrumentcall together with--generate-function-bodyworks just fine and does exactly the right thing. I will nevertheless issue two follow-up PRs:goto-instrumentto make sure that--add-libraryworks correctly with all code transformations.Generate-function-bodies: generate a meaningful assertion
Generate-function-bodies: generate a meaningful assertion