Skip to content

0.3.0

Choose a tag to compare

@sonic182 sonic182 released this 09 Nov 16:34
· 129 commits to main since this release
8ded9b8

cchecker 0.3.0 has fewer false positives on code that cannot be marked (vendored libraries, interpreters that longjmp), and it no longer loses findings without a word.

  • Jumps: CC_JUMPS and [assume] jumps mark a raiser that never returns: its call is a way out where a pointer that still owns is CC-OWN-LEAK and a held lock is CC-PATH-LOCK-NOT-RELEASED. may_jump now spreads through the call graph unless a function catches (setjmp, CC_CATCHES). CC_JUMP_RELEASES / [assume] jump_releases cover a lock that the catcher gives back.
  • Settings for code you cannot edit:
    • [assume] acquires and releases mark lock wrappers.
    • [assume] stop_calls cuts one call edge.
    • [assume] nonblocking names the functions whose descriptors are non-blocking.
    • [roots] and [assume] take name@path for static functions.
  • Calls that do not block: uv_run with UV_RUN_NOWAIT, waitpid/wait3/wait4/waitid with WNOHANG, and a flag held in a local variable set before the call.
  • The compile database: a file listed twice is checked once. [database] fold_ignoring folds entries that differ only in named defines.
  • Fixed:
    • clang-tidy findings are no longer dropped without a word under UseColor: true.
    • --checks '-*,...' now works: an option value may start with -.
  • Experimental, off by default: [library] short_lock_sections = true infers short locks from their critical sections.

Breaking:

  • CC_MAY_JUMP on a function that never returns now means CC_JUMPS.
  • The inference of may_jump ([library] may_jump_callers) may add findings that your baseline does not hold. Run --update-baseline once after upgrading.

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

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

Changelog

Added

  • waitpid, wait3, wait4 and waitid with WNOHANG are not blocking calls for CC_SHORT
    (libc_nonblocking_flags).
  • The flag of libc_nonblocking_flags may be in a local variable that gets only constants and gets one before the
    call on every path (options = WNOHANG; waitpid(pid, &status, options)).
  • [assume] nonblocking = ["uv__read"]: the calls on a descriptor (read, write, recv, send, accept, ...)
    that these functions make are not blocking for CC_SHORT, for code whose descriptors are all non-blocking.
  • [assume] acquires and releases ("my_lock(0)", "name@path(N)") mark a lock wrapper of code that cannot be
    edited as CC_ACQUIRES and CC_RELEASES do, with the parameter that holds the lock. short_locks takes the same
    name(N) for a wrapper whose lock cannot be named: every lock taken through it is short.
  • [database] fold_ignoring = ["NAME"]: two entries of one file that differ only in those defines (any value) are
    checked once, the first of the database, like the -D<target>_EXPORTS of a shared library (libuv's
    BUILDING_UV_SHARED). A define that changes the C the rules read hides it from the entries left out.
  • [assume] stop_calls = ["caller>callee"] cuts the calls of callee in caller out of the call graph, for every rule
    that walks it (effects, the lock rules' system path, the inference of may_jump_callers); the callee stays reachable
    from its other callers, where stop removes it for all. Each side takes name@path, and a pair that matches no
    call is exit 2.
  • uv_walk: its callback, and a function stored in the exit_cb of uv_process_options_t, are CC_SHORT roots like the
    other callbacks of libuv that run on the loop (libuv_callbacks_short).
  • [roots] and [assume] (short, stop, may_jump, jumps, catches, jump_releases) take name@path, the
    function of that name whose file ends with path, so a name shared by static functions of several files no longer
    marks all of them.
  • CC_JUMPS and [assume] jumps: a call of a function that always jumps out and never returns (an interpreter's raise
    with longjmp) is a way out of its caller, where a pointer that still owns is CC-OWN-LEAK and a lock held is
    CC-PATH-LOCK-NOT-RELEASED, and the path ends there.
  • A function that calls a function that may jump out or jumps may jump out too, unless it calls setjmp or
    sigsetjmp or is marked CC_CATCHES (or [assume] catches): only the raisers need a mark. The last step of path
    names the chain of calls (may jump in path_of (as_string, wrong_tag)), and such a finding has
    "source":"may_jump_callers"; [library] may_jump_callers = false turns the inference off. Breaking: a project
    with CC_MAY_JUMP marks may get new findings that its baseline does not hold.
  • CC_JUMP_RELEASES and [assume] jump_releases on a CC_ACQUIRES or CC_RELEASES helper whose lock the catcher
    of a jump gives back: a jump with that lock held or released is no lock finding when the function takes and
    releases it only through such helpers; a return still is.
  • Experimental, off by default: with [library] short_lock_sections = true, a lock whose critical sections reach no
    blocking call, in a full run of a compile database, is short for CC_SHORT, as with [assume] short_locks;
    inferred_short_locks of --json lists them and the text report counts them. It may call a lock short wrongly in
    cases it does not handle yet; turn it on only to try it.

Changed

  • uv_run with a constant UV_RUN_NOWAIT is no longer a blocking call for CC_SHORT (libc_nonblocking_flags);
    UV_RUN_ONCE, UV_RUN_DEFAULT and a mode in a variable still are.
  • Breaking: CC_MAY_JUMP or [assume] may_jump on a function that never returns (_Noreturn, CC_NORETURN) now
    means CC_JUMPS: its calls are checked as a way out, where before they only ended the path and found nothing. A
    project with that combination may get new findings that its baseline does not hold.
  • A file listed more than once with the same flags is checked once; flags that differ only by -fPIC, -fPIE and
    CMake's -D<target>_EXPORTS count as the same (a static and a shared library of CMake), any other define does not
    (libuv's BUILDING_UV_SHARED keeps both entries). folded of --json counts the repeated entries left out.

Fixed

  • A .clang-tidy with UseColor: true, or a -fdiagnostics-color=always or -fdiagnostics-urls=always in the
    flags, no longer drops or renames the findings of that tool without a word: cchecker turns colours and links off
    after the project's settings, and a diagnostic line that it cannot read is a tool error (exit 2).
  • A value that starts with - is taken from the next word, as getopt does: --checks '-*,bugprone-*' works like
    --checks='-*,bugprone-*' instead of saying that --checks needs a value (and -j -1 now says that -1 is too
    small).