Repository navigation
0.3.0
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_JUMPSand[assume] jumpsmark a raiser that never returns: its call is a way out where a pointer that still owns isCC-OWN-LEAKand a held lock isCC-PATH-LOCK-NOT-RELEASED.may_jumpnow spreads through the call graph unless a function catches (setjmp,CC_CATCHES).CC_JUMP_RELEASES/[assume] jump_releasescover a lock that the catcher gives back. - Settings for code you cannot edit:
[assume] acquiresandreleasesmark lock wrappers.[assume] stop_callscuts one call edge.[assume] nonblockingnames the functions whose descriptors are non-blocking.[roots]and[assume]takename@pathfor static functions.
- Calls that do not block:
uv_runwithUV_RUN_NOWAIT,waitpid/wait3/wait4/waitidwithWNOHANG, and a flag held in a local variable set before the call. - The compile database: a file listed twice is checked once.
[database] fold_ignoringfolds 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-.
- clang-tidy findings are no longer dropped without a word under
- Experimental, off by default:
[library] short_lock_sections = trueinfers short locks from their critical sections.
Breaking:
CC_MAY_JUMPon a function that never returns now meansCC_JUMPS.- The inference of
may_jump([library] may_jump_callers) may add findings that your baseline does not hold. Run--update-baselineonce 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.jsonChangelog
Added
waitpid,wait3,wait4andwaitidwithWNOHANGare not blocking calls forCC_SHORT
(libc_nonblocking_flags).- The flag of
libc_nonblocking_flagsmay 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 forCC_SHORT, for code whose descriptors are all non-blocking.[assume] acquiresandreleases("my_lock(0)","name@path(N)") mark a lock wrapper of code that cannot be
edited asCC_ACQUIRESandCC_RELEASESdo, with the parameter that holds the lock.short_lockstakes 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>_EXPORTSof 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 ofcalleeincallerout of the call graph, for every rule
that walks it (effects, the lock rules' system path, the inference ofmay_jump_callers); the callee stays reachable
from its other callers, wherestopremoves it for all. Each side takesname@path, and a pair that matches no
call is exit 2.uv_walk: its callback, and a function stored in theexit_cbofuv_process_options_t, areCC_SHORTroots 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) takename@path, the
function of that name whose file ends withpath, so a name shared by static functions of several files no longer
marks all of them.CC_JUMPSand[assume] jumps: a call of a function that always jumps out and never returns (an interpreter's raise
withlongjmp) is a way out of its caller, where a pointer that still owns isCC-OWN-LEAKand 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
setjmpor
sigsetjmpor is markedCC_CATCHES(or[assume] catches): only the raisers need a mark. The last step ofpath
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 = falseturns the inference off. Breaking: a project
withCC_MAY_JUMPmarks may get new findings that its baseline does not hold. CC_JUMP_RELEASESand[assume] jump_releaseson aCC_ACQUIRESorCC_RELEASEShelper 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 forCC_SHORT, as with[assume] short_locks;
inferred_short_locksof--jsonlists 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_runwith a constantUV_RUN_NOWAITis no longer a blocking call forCC_SHORT(libc_nonblocking_flags);
UV_RUN_ONCE,UV_RUN_DEFAULTand a mode in a variable still are.- Breaking:
CC_MAY_JUMPor[assume] may_jumpon a function that never returns (_Noreturn,CC_NORETURN) now
meansCC_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,-fPIEand
CMake's-D<target>_EXPORTScount as the same (a static and a shared library of CMake), any other define does not
(libuv'sBUILDING_UV_SHAREDkeeps both entries).foldedof--jsoncounts the repeated entries left out.
Fixed
- A
.clang-tidywithUseColor: true, or a-fdiagnostics-color=alwaysor-fdiagnostics-urls=alwaysin 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--checksneeds a value (and-j -1now says that-1is too
small).