Skip to content

0.4.0

Choose a tag to compare

@sonic182 sonic182 released this 09 Nov 22:31
· 76 commits to main since this release
4b17d20

cchecker 0.4.0 follows ownership more closely (struct fields, a pointer saved before it is replaced, inner blocks) and gives fewer false findings on common C idioms.

  • Owned fields: the ownership rules follow the CC_OWNS fields of a local struct used field by field (p.left, also from an initializer or a compound literal).
  • Saved pointers: after old = p;, a new value of p leaves the old pointer to old, so the TAKE_PTR idiom (old = p; p = NULL;) is no longer a false leak or double free.
  • Blocks and shadowing: a leak of a pointer declared in an inner block is reported where the path leaves the block. A local that shadows another has its own state.
  • Statement expressions: return ({ ...; p; }) and free(({ ...; p; })) hand on or free p, and a statement-expression macro used many times no longer leaves the function incomplete.
  • Path rules: a condition is forgotten after its last test, so many independent flags no longer multiply the states or give false findings.
  • Short locks: [assume] owned_locks names the pointer fields and globals that point to a mutex of their own.
  • Docs: the docs are now a site, https://agentica-lang.github.io/cchecker/, with search and a Markdown copy of each page.

Breaking:

  • cchecker needs Agentica 0.27.0 or later.
  • A CC_OWNS field of a local struct that is not freed or handed on is now a CC-OWN-LEAK.
  • After old = p;, the leak of the old pointer is reported on old, no longer as an overwrite of p.
  • Run --update-baseline once after upgrading.

Install and run (needs Agentica 0.27.0+, gcc 10+, clang and clang-tidy):

git clone --branch 0.4.0 https://github.com/agentica-lang/cchecker ~/cchecker
agentica ~/cchecker/cchecker.agc -p build    # in your project, with build/compile_commands.json

Changelog

Added

  • The docs as a site, https://agentica-lang.github.io/cchecker/, with search and a Markdown copy of each page.
  • [assume] owned_locks names the pointer fields and globals that point to a mutex of their own
    (lock.mutex): the inference of short locks gives such a lock the class of the pointer instead of stopping.

Changed

  • Breaking: cchecker needs Agentica 0.27.0 or later (native-gen makes the C side of its scan module).
  • Breaking: the ownership rules follow the CC_OWNS fields of a local struct that the function uses only field by
    field (p.left, also from an initializer): a field that is not freed or handed on is a CC-OWN-LEAK, where a store
    into it used to hand the pointer on. Run --update-baseline once after upgrading.
  • Breaking: after old = p;, a new value of p (p = make(), p = NULL, take(&p)) leaves the old pointer to
    old: its leak is reported on old, no longer as an overwrite of p. Run --update-baseline once after upgrading.
  • A leak of a pointer declared in an inner block is reported where the path leaves the block (its end, a break,
    continue, goto or return), not at the end of the function.
  • The path rules forget a condition after its last test: many independent flags (if (a) lock(); if (a) unlock();)
    no longer multiply the states, nor fall back to the walk without conditions, which gave false findings.

Fixed

  • The TAKE_PTR idiom (old = p; p = NULL;), and a pointer that an initializer or a compound literal puts in a
    CC_OWNS field, are no longer a false CC-OWN-LEAK or CC-OWN-DOUBLE-FREE.
  • A local that shadows another (a parameter, a global, a local of an outer block) has its own state, so it no longer
    gives false CC-OWN or lock findings or hides real ones.
  • A statement expression returned, passed to a call or in a ?: (return ({ ...; p; }), free(({ ...; p; }))) hands
    on or frees p: no longer a false CC-OWN-LEAK.
  • A statement-expression macro used many times into one variable (s = TAKE(); if (s) free(s);) no longer leaves the
    function in incomplete_functions.