Case 231: Return Value Units Changed¶
| Field | Value |
|---|---|
| Verdict | ✅ NO_CHANGE |
| Category | No Change |
| Classification | Rule |
| Platforms | Linux |
| Flags | Bad practice |
Detected ChangeKinds |
— |
| Source files | catalog/cases/case231_return_value_units_changed/ |
| Rule family | return-value-units-changed |
| Subject | Behavioral breaks outside static evidence |
Category: No Change (declared interface) | Verdict: ✅ NO_CHANGE — with a separate behavioral break
Verdict and consumer impact¶
net::session_timeout() keeps its declaration, symbol and return type
(long). The documented unit is seconds; v2 returns milliseconds (30 →
30000). Every old consumer that follows the documentation now waits a
thousand times longer: a 30-second idle timeout becomes about 8 hours.
This is a behavioral break, not a source (API) or binary (ABI) break. As
a statement about the declared interface the verdict is NO_CHANGE, and that
stays true even with build data and sources (see below). The break is
recorded in ground_truth.json as behavioral_break: true with
truth_scope: declared-interface.
Old/new diff¶
| v1.cpp | v2.cpp |
|---|---|
return 30; // seconds |
return 30000; // milliseconds |
v1.h and v2.h are identical.
abicheck command¶
g++ -shared -fPIC -g v1.cpp -o libv1.so
g++ -shared -fPIC -g v2.cpp -o libv2.so
abicheck compare libv1.so libv2.so --header old=v1.h --header new=v2.h
Expected abicheck finding¶
Compatibility: NO_CHANGE | Policy: strict_abi | Gate: ACCEPTED (exit 0)
Findings: 0 detected; 0 retained (0 gating, 0 non-gating); 0 review groups.
No ChangeKind is expected. The absence is the detection control; the
behavioral regression is recorded separately.
Minimum evidence¶
min_evidence: L2. The public header AST is what establishes that the
published declaration is unchanged. Nothing deeper adds a fact: the case
was also compared at --depth source with compile_commands.json and both
source trees, and the result is still NO_CHANGE.
Why abicheck reports nothing¶
abicheck's deterministic checks compare what the artifacts declare:
exported symbols, DWARF types and layout, header declarations, build flags,
and source-graph dependencies. All of those are identical here. The change
sits in an out-of-line function body, and its meaning (the unit of the returned number) exists only in
documentation. No static rule can tell a bug fix from a contract break in a
function body, so abicheck correctly does not guess. That is why
ground_truth.json records truth_scope: declared-interface and a separate
behavioral_break: true: NO_CHANGE here does not mean "safe to ship".
See Behavioral & Semantic Compatibility.
Runtime failure demonstration¶
Severity: an unchanged old consumer breaks at runtime; no static tool shows it.
g++ -shared -fPIC -g v1.cpp -o libv1.so
g++ -g app.cpp -L. -lv1 -Wl,-rpath,'$ORIGIN' -o app
./app # session timeout = 30 s exit 0
g++ -shared -fPIC -g v2.cpp -o libv1.so # swap in v2, no recompile
./app # session timeout = 30000 s
# WRONG RESULT: timeout is no longer in seconds exit 1
Safe redesign¶
Put the unit in the type, so the compiler and abicheck can see it: return
std::chrono::seconds instead of long. Changing that later to
std::chrono::milliseconds changes the return type, which abicheck reports
(func_return_changed). Old consumers that stored the result in
std::chrono::seconds then fail to compile instead of silently computing a
wrong deadline: milliseconds does not convert implicitly to seconds, and
an explicit duration_cast makes the possible loss of precision visible. Both
are far better than a wrong value at runtime. Changing the return type of an
exported function in place is itself an ABI break, so do it through a new
function or in an ABI-major release.
With a plain number, add a new function (session_timeout_ms()) and keep the
old one in seconds.
Cross-tool comparison¶
abidiff and ABICC also report no change: they compare the same symbols,
types and declarations. Catching this break needs a test that runs a consumer
against the new library (the app.cpp above is such a test).
Ground-truth provenance¶
Behavioral break: Not a compatibility claim for the release. A static comparison at every evidence depth (binary, headers, build data, sources) sees the same declaration, the same symbol and the same layout, so NO_CHANGE is the truth only for the declared interface. The runtime witness breaks a valid old consumer: app.cpp treats the value as seconds, as documented, exits 0 against v1 and reports a timeout of 30000 s and exits 1 against v2. A unit lives in documentation, not in the type long, so no deterministic detector can see the change.
Source files¶
CMakeLists.txtapp.cppv1.cppv1.hv2.cppv2.h
See also: Compatibility Catalog · All NO_CHANGE cases · Category: No Change · Rule: Return value units changed · Subject: Behavioral breaks outside static evidence.