Skip to content

"Array Subscript Out Of Range" Exception Can Be Thrown Under A Floating Point Rounding Edge Case. #2220

@SimonCSmith

Description

@SimonCSmith

I'm getting an "array subscript out of range" exception (Windows, Debug Build, OCIO 2.5.0) inside of reach_m_from_table due to a hue of 360.0 being passed in. This causes a i_lo=361, and i_hi=362. Given the ACES2::Table1D rt is only 362 in size, you get the overrun access scenario.

The reason you can get a hue of 360.0 is due to floating point rounding issues. These step from the calculations in the fwd call.

The RGB values coming into Renderer_ACES_OutputTransform20::fwd

0.742242277
0.0931933373
0.321542144

ACES2::RGB_to_Aab converts to

0.659631252
103.849297
-2.28881836e-05

Then ACES2::Aab_to_JMh converts it on to

62.3068
103.850
360.000

The atan2() in the Aab_to_JMh returns -2.20398064e-07, which then results in -1.26278792e-05 going into the _wrap_to_hue_limit call, and adding that to 360.000000 leaves it at a value of 360.000000.

Note that the random data obtained from the buffer over-read is technically immaterial (as it's multiplied by 0 in the lerp call) but it does mean you get an exception firing off due to Windows _STL_VERIFY macro which halts execution in the debugger.

For context, the processor I had at the time of the exception had a source of OCIO::ROLE_SCENE_LINEAR, and display/view of "sRGB - Display" and "ACES 2.0 - SDR 100 nits (Rec.709)" from the ACES2.0cg configuration (cg-config-v4.0.0_aces-v2.0_ocio-v2.5)

  • Simon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions