Memory is freed twice
What it finds
delete p; or free(p); and later the same again on some path, with nothing in between that gives p a new value: the memory is released twice, which corrupts the heap.
``cpp delete node; if (retry) goto again; // again: deletes node once more ``
The rule follows each function on its paths, as use-after-free does: only local variables and parameters, as SSA values, so a pointer assigned anew or whose address is taken is not reported, and paths that cannot follow one another are kept apart. Functions with constructs the lowering does not understand are skipped.
From the rule's source, double_free.rs.
Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/cpp:double-free" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/cpp:double-free] reason="..."tx0 explain tx0/cpp:double-free shows the same in the terminal. Found a false positive? Report it.