Description
CBMC version: 5.12.1
Operating system: MacOS
Exact command line resulting in the issue:
What behaviour did you expect:
What happened instead:
In error traces, for the function malloc, the function call is set to visible and the function return is set to hidden.
Can anyone help me debug this?
If I take the program main.c
#include <stdlib.h>
#include <assert.h>
main() {
int x = malloc(sizeof(int));
assert(0);
}
and run the command
cbmc --xml-ui --trace main.c
the xml output includes the tags
<function_call hidden="false" step_nr="29" thread="0">
<function display_name="malloc" identifier="malloc">
<location file="<builtin-library-malloc>" line="6" working-directory="/private/tmp"/>
</function>
<location file="main.c" function="main" line="5" working-directory="/private/tmp"/>
</function_call>
and
<function_return hidden="true" step_nr="48" thread="0">
<function display_name="malloc" identifier="malloc">
<location file="<builtin-library-malloc>" line="6" working-directory="/private/tmp"/>
</function>
<location file="<builtin-library-malloc>" function="malloc" line="57" working-directory="/private/tmp"/>
</function_return>
The call is visible and the return is hidden.
Similar incorrect behavior for the built-in function getenv
#include <stdlib.h>
#include <stdbool.h>
main() {
bool b = getenv("S2N_DONT_MLOCK");
assert(0);
}
<function_call hidden="false" step_nr="29" thread="0">
<function display_name="getenv" identifier="getenv">
<location file="<builtin-library-getenv>" line="14" working-directory="/private/tmp/test"/>
</function>
<location file="main.c" function="main" line="5" working-directory="/private/tmp/test"/>
</function_call>
<function_return hidden="true" step_nr="36" thread="0">
<function display_name="getenv" identifier="getenv">
<location file="<builtin-library-getenv>" line="14" working-directory="/private/tmp/test"/>
</function>
<location file="<builtin-library-getenv>" function="getenv" line="47" working-directory="/private/tmp/test"/>
</function_return>
But surprisingly correct behavior for the built-in function __builtin_alloca
(the example below is for an invocation of the built-in __builtin_alloca
nested within an invocation of the built-in getenv
):
<function_call hidden="true" step_nr="522" thread="0">
<function display_name="__builtin_alloca" identifier="__builtin_alloca">
<location file="<builtin-library-__builtin_alloca>" line="5" working-directory="...deleted..."/>
</function>
<location file="<builtin-library-getenv>" function="getenv" line="42" working-directory="...deleted..."/>
</function_call>
<function_return hidden="true" step_nr="540" thread="0">
<function display_name="__builtin_alloca" identifier="__builtin_alloca">
<location file="<builtin-library-__builtin_alloca>" line="5" working-directory="...deleted..."/>
</function>
<location file="<builtin-library-__builtin_alloca>" function="__builtin_alloca" line="25" working-directory="...deleted..."/>
</function_return>
The hidden attribute of an xml step appears to come from a trace step which appears to come from an ssa step, and the hidden attribute on an ssa step appears to be set in goto_convert_functionst::hide
. I can't see where the inconsistency would be coming from.