Skip to content

Hidden attribute for malloc is inconsistent in traces #5413

Closed
@markrtuttle

Description

@markrtuttle

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="&lt;builtin-library-malloc&gt;" 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="&lt;builtin-library-malloc&gt;" line="6" working-directory="/private/tmp"/>
      </function>
      <location file="&lt;builtin-library-malloc&gt;" 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="&lt;builtin-library-getenv&gt;" 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="&lt;builtin-library-getenv&gt;" line="14" working-directory="/private/tmp/test"/>
  </function>
  <location file="&lt;builtin-library-getenv&gt;" 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="&lt;builtin-library-__builtin_alloca&gt;" line="5" working-directory="...deleted..."/>
  </function>
  <location file="&lt;builtin-library-getenv&gt;" 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="&lt;builtin-library-__builtin_alloca&gt;" line="5" working-directory="...deleted..."/>
  </function>
  <location file="&lt;builtin-library-__builtin_alloca&gt;" 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    awsBugs or features of importance to AWS CBMC users

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions