You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fl_gfx_rgbww: stale pointer-identity assertion after by-value contract migration (#2580) #2603
fl_gfx_rgbww fails the "rgbww colorimetric profile get/set API" test case at tests/fl/gfx/rgbww.cpp:188:
FAIL: rgbww colorimetric profile get/set API at ../../tests/fl/gfx/rgbww.cpp:179
../../tests/fl/gfx/rgbww.cpp:188: after == &custom
Reproducible: any host build (bash test fl_gfx_rgbww --cpp).
Root cause
PR #2580 (CodeRabbit finding A4 from #2560) deliberately changed set_rgbww_colorimetric_profile() from stashing the caller's raw pointer to copying by value into a singleton-owned RgbwwColorimetricState::profile. The motivation was a dangling-pointer bug: callers commonly pass &local_var from setup(), and the stashed pointer was invalid once setup() returned.
src/fl/gfx/rgbww.cpp.hpp:87-100:
voidset_rgbww_colorimetric_profile(const colorimetric_detail::RgbcctProfile* profile) FL_NOEXCEPT {
RgbwwColorimetricState& state = fl::Singleton<RgbwwColorimetricState>::instance();
if (profile == nullptr) { state.has_profile = false; return; }
state.profile = *profile; // ← copy by value
state.has_profile = true;
}
const colorimetric_detail::RgbcctProfile* get_rgbww_colorimetric_profile() FL_NOEXCEPT {
const RgbwwColorimetricState& state = fl::Singleton<RgbwwColorimetricState>::instance();
return state.has_profile ? &state.profile : &kRgbwwDefaultProfile;
}
But the test at line 188 still asserts pointer identity with the caller's address:
const colorimetric_detail::RgbcctProfile* after = get_rgbww_colorimetric_profile();
FL_CHECK(after == &custom); // ← FAILS — `after` is &state.profile, not &custom
If this assertion were to pass, it would mean the dangling-pointer bug had been reintroduced.
Fix
Update the test to assert the by-value contract instead of pointer identity:
FL_CHECK(after != nullptr);
FL_CHECK(after != &custom); // distinct from caller's addressFL_CHECK(after != &kRgbwwDefaultProfile); // set actually took effectFL_CHECK_CLOSE(after->warm_path.lum_w, 0.5f, 1e-6f); // value flowed through
This tests what the implementation actually promises and would catch a regression to the dangling-pointer behavior.
Test plan
bash test fl_gfx_rgbww --cpp — passes (was red).
bash test fl_gfx_rgbww --debug — passes with ASAN/UBSAN/LSAN.
Surfaced by the Stop hook during an unrelated sweep on master.
Activity
fix(test): rgbww profile API — assert by-value contract, not pointer …