Skip to content

Use TfHash in __hash__ implementations in pxr/base/gf#2329

Merged
pixar-oss merged 1 commit intoPixarAnimationStudios:devfrom
nvmkuruc:gfpyhash
Apr 3, 2023
Merged

Use TfHash in __hash__ implementations in pxr/base/gf#2329
pixar-oss merged 1 commit intoPixarAnimationStudios:devfrom
nvmkuruc:gfpyhash

Conversation

@nvmkuruc
Copy link
Copy Markdown
Collaborator

@nvmkuruc nvmkuruc commented Mar 13, 2023

Description of Change(s)

#2175 replaced usage of boost::hash_value and boost::hash_combine with their TfHash equivalents in C++. This completes the removal of boost/functional/hash.hpp from pxr/base/gf by exclusively using TfHash in the python bindings.

Fixes Issue(s)

  • I have verified that all unit tests pass with the proposed changes
  • I have submitted a signed Contributor License Agreement

@sunyab
Copy link
Copy Markdown
Contributor

sunyab commented Mar 14, 2023

Filed as internal issue #USD-8090

@pixar-oss pixar-oss merged commit da2b53c into PixarAnimationStudios:dev Apr 3, 2023
@nvmkuruc nvmkuruc deleted the gfpyhash branch December 29, 2023 03:10
musicinmybrain pushed a commit to musicinmybrain/OpenUSD that referenced this pull request Apr 7, 2026
…ithmetic (PixarAnimationStudios#2329)

`numBlocksX` and `numBlocksY` are declared as `int`. Two pointer-offset
expressions in `LossyDctDecoder_execute()` multiplied them as signed
32-bit integers before using the result as a pointer offset:

    rowBlock[comp]   = rowBlock[comp - 1]   + numBlocksX * 64;
    currDcComp[comp] = currDcComp[comp - 1] + numBlocksX * numBlocksY;

`dataWindow.max.x` is a signed 32-bit value in the EXR file format, so
`numBlocksX` can reach `(INT32_MAX + 7) / 8 = 268,435,456`. At that
point `numBlocksX * 64 = 17,179,869,184` overflows `int32`, and
`numBlocksX * numBlocksY` overflows even sooner. The wraparound
produces a small or negative pointer offset, causing `rowBlock[comp]`
and `currDcComp[comp]` to point into already-used or pre-buffer memory
rather than the intended component stride.

Fix: cast `numBlocksX` to `size_t` before multiplying so the
arithmetic is performed in pointer-sized unsigned arithmetic:

    rowBlock[comp]   = rowBlock[comp - 1]   + (size_t) numBlocksX * 64;
    currDcComp[comp] = currDcComp[comp - 1] + (size_t) numBlocksX * numBlocksY;

This is consistent with the allocation on the line above, which already
uses `(size_t) numComp * (size_t) numBlocksX * 64 * sizeof(uint16_t)`,
and with the packed-DC count check, which uses explicit `uint64_t` casts.

Made-with: Cursor

Signed-off-by: Cary Phillips <cary@ilm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants