Repository navigation
Description
Problem
The DoubleRelease counters count releases and acquisitions per variable and per summary effect,
not per value and not per path. Two shapes keep producing false positives:
A variable released, given an unrelated pointer, then released again.
// resource-model: models/resource-lifetime/generic.txt
#include <stdlib.h>
extern void* unknown_ptr(void);
void reassign_unknown(void)
{
char* p = malloc(8);
free(p);
p = unknown_ptr(); /* not a modeled acquire */
free(p); /* reported: potential double release */
}This is pattern 2 of the #104 comment of 2026-10-26 in its DoubleRelease form; the
UseAfterRelease form was fixed by #270. The sudo plugins/sudoers/editor.c:166 shape from the
same comment (value from an unmodeled source, moved into an array, local set to NULL, released
at a cleanup label) reaches the same counters through the "released without a matching acquire"
check.
Two parameters of one call that release the same pointer on exclusive paths.
static void release_one(void* a, void* b, int c)
{
if (c)
free(a);
else
free(b);
}
void release_one_same_pointer(int c)
{
char* p = malloc(8);
release_one(p, p, c); /* reported: potential double release */
}The counters add the two summary releases of release_one. The ownership engine's
per-parameter summaries do not know that the two releases exclude each other either: the same
call also gets a MissingRelease ("may leave the function").
Context
- With the engine-based DoubleRelease planned for DoubleRelease and UseAfterRelease: derive them from the ownership engine #104, the counters only decide where the
engine has no verdict: contents unknown to the engine, uncertain resources, releases inside
loops, releases of one call whose joint execution is not established. Today they decide
everywhere. - The "release without acquire" check (
release-without-acquire-still-errors.cpp) is kept as a
fallback for now (decision in DoubleRelease and UseAfterRelease: derive them from the ownership engine #104). It flags an ownership mismatch, not a proven double
release. - Work item 3 of DoubleRelease and UseAfterRelease: derive them from the ownership engine #104 (remove the counters) is still open for DoubleRelease.
Goal
Decide what replaces the counters where the engine has no verdict, then remove them: a per-value
fallback, an engine check for "release of a location holding no owned resource", or both.
Acceptance
reassign_unknownandrelease_one_same_pointerabove: noDoubleRelease.release-without-acquire-still-errors.cpp: the outcome chosen in DoubleRelease and UseAfterRelease: derive them from the ownership engine #104 for the fallback.
Part of #104.
Activity