Repository navigation
0.4.0
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_OWNSfields 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 ofpleaves the old pointer toold, 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; })andfree(({ ...; p; }))hand on or freep, 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_locksnames 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_OWNSfield of a local struct that is not freed or handed on is now aCC-OWN-LEAK. - After
old = p;, the leak of the old pointer is reported onold, no longer as an overwrite ofp. - Run
--update-baselineonce 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.jsonChangelog
Added
- The docs as a site, https://agentica-lang.github.io/cchecker/, with search and a Markdown copy of each page.
[assume] owned_locksnames 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_OWNSfields 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-baselineonce after upgrading. - Breaking: after
old = p;, a new value ofp(p = make(),p = NULL,take(&p)) leaves the old pointer to
old: its leak is reported onold, no longer as an overwrite ofp. Run--update-baselineonce 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,gotoorreturn), 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_OWNSfield, 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 freesp: 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 inincomplete_functions.