Skip to content

Conversation

@KevinJW
Copy link
Contributor

@KevinJW KevinJW commented Dec 24, 2025

Reproduced #2220

Using Debug build on Windows 11 using VS 2022 Community edition:

  1. Open VS 2022 Developer Console
  2. Clone OpenColorIO main branch
  3. Add new aces_ot_20_edge_cases test from this branch
  4. Configure for Debug build
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=c:\Temp -DCMAKE_BUILD_TYPE=Debug ..
cmake --build . --config Debug --parallel
  1. Run ctest

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

Code incorrectly deals with edge cases where atan2() returns end of range [-pi, pi]

Signed-off-by: Kevin Wheatley <kevin.wheatley@framestore.com>
@KevinJW KevinJW self-assigned this Dec 24, 2025
@KevinJW KevinJW added the Bug Unwanted or incorrect behavior in currently available functionality. label Dec 24, 2025
@KevinJW
Copy link
Contributor Author

KevinJW commented Dec 24, 2025

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>
@KevinJW KevinJW force-pushed the bug/2220-array-subscript-out-of-range-exception-can-be-thrown-under-a-floating-point-rounding-edge-case branch from 4a6c058 to f774cbe Compare December 24, 2025 14:32
@KevinJW KevinJW requested a review from Copilot December 24, 2025 14:58
Copy link

Copilot AI left a 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>
Copy link
Collaborator

@doug-walker doug-walker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Unwanted or incorrect behavior in currently available functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants