-
Notifications
You must be signed in to change notification settings - Fork 481
Bug/2220 array subscript out of range exception can be thrown under a floating point rounding edge case #2227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Code incorrectly deals with edge cases where atan2() returns end of range [-pi, pi] Signed-off-by: Kevin Wheatley <kevin.wheatley@framestore.com>
|
Just to note whatever the solution it should probably be back ported to 2.4.x branch. Something to discuss in next TSC |
…ion to not over flow table bounds during lookup All tables are now 1 entry larger and should have valid data wrapped into the extra entries Signed-off-by: Kevin Wheatley <kevin.wheatley@framestore.com>
4a6c058 to
f774cbe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes an array subscript out of range exception in the ACES2 output transform that can occur due to floating-point rounding edge cases when hue angles are near the boundary of the 360-degree hue range. The fix adds an additional entry at the upper wrap boundary of internal lookup tables to ensure interpolation never accesses memory beyond the allocated array.
Key Changes:
- Modified table size calculation to add an extra upper boundary entry
- Updated four table initialization functions to populate the new boundary entry
- Added a regression test case that reproduces the edge case from issue #2220
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/OpenColorIO/ops/fixedfunction/ACES2/Common.h |
Modified TableBase struct to increase total table size from nominal_size + 2 to nominal_size + 3 entries by splitting the addition constants |
src/OpenColorIO/ops/fixedfunction/ACES2/Transform.cpp |
Updated four table builder functions (build_hue_table, build_cusp_table, make_reach_m_table, make_upper_hull_gamma) to populate the new upper_wrap_index + 1 entry with wrapped values for continuity |
tests/cpu/ops/fixedfunction/FixedFunctionOpCPU_tests.cpp |
Added new test case aces_ot_20_edge_cases with specific RGB values that trigger the boundary condition |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…cess bug Signed-off-by: Kevin Wheatley <kevin.wheatley@framestore.com>
doug-walker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Reproduced #2220
Using Debug build on Windows 11 using VS 2022 Community edition:
Fix is to add an additional entry at the end of the tables, to handle the boundary condition due to atan2() returning the interval [-pi, +pi] each new entry filled with the corresponding entry from the lower entries to maintain continuity