Skip to content

Performance problem with --pointer-checks, --pointer-primitive-checks #7378

Closed
@remi-delmas-3000

Description

@remi-delmas-3000

This branch contains the problematic model https://github.com/remi-delmas-3000/cbmc/tree/record-write-v-minimized

The s2n_record_writev.c model reveals several problems, described in regression/contracts/s2n_record_writev/RUNME.sh.

In short:

  • translating the model with goto-cc s2n_record_writev.c produces a model a.out that can be analysed directly by cbmc with pointer checks and pointer primitive checks without problems.
  • running a single pass of goto-instrument a.out b.out without options turns a.out into a slightly different model b.out that makes cbmc --pointer-checks --pointer-primitive-checks b.out explode in size during CNF translation
  • A nondet pointer assignment to a pointer packed in a struct s2n_hash_state seems to have a side effect on another pointer of the struct (removing the nondet assignment from the C file solves all performance problems);
  • Slight alterations of the PO formulation assert(pointer_offset(object) >= constant) instead of assert(!(pointer_offset(object) < constant)) seems to result in large CNF size differences;
  • Possibly lacking common subexpression reuse in automatically generated rw_ok checks and pointer checks (the expression of the pointer being checked contains byte_extracts and has multiple individual occurrences in the check expression.);
  • What could also be happening is that the goto-instrument pass expands the rw_ok assertion contained in a.out and that the resulting expressions in b.out get themselves instrumented as if they were user code. (this could explain the difference in number of generated POs between a.out (Generated 445 VCC(s), 19 remaining after simplification) and b.out (Generated 529 VCC(s), 103 remaining after simplification)).

It could be possible to add disable:pointer-check, disable:pointer-primitive-check, disable:pointer-overflow-check pragmas to avoid the expanded expression being itself instrumented in later passes (if this is what happens).

CBMC version: 5.70 +
Operating system: linux, macOS
Exact command line resulting in the issue: see regression/contracts/s2n_record_writev/RUNME.sh
What behaviour did you expect: analysis terminates
What happened instead: analysis saturates RAM (128gigs)

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions