GraphEngine icon indicating copy to clipboard operation
GraphEngine copied to clipboard

Fix(MemoryTrunk.DefragTwoRegion): Unsigned difference expression compared to zero

Open opsysdebug opened this issue 5 months ago • 0 comments

https://github.com/microsoft/GraphEngine/blob/e3c0e1946d5a49612ac394593de8145594efbdc5/src/Trinity.C/src/Storage/MemoryTrunk/MemoryTrunk.DefragTwoRegion.cpp#L43-L43

Fix the issue the result of the subtraction hole_right_offset - _bwd_cell_offset - _bwd_cell_size should be cast to a signed type (e.g., int64_t) before performing the comparison. This ensures that the subtraction can produce negative values, and the comparison > 0 will behave as intended.

Steps to fix:

  1. Cast the result of the subtraction to int64_t before performing the comparison.
  2. Ensure that the cast does not affect other parts of the code or introduce unintended side effects.

opsysdebug avatar May 28 '25 09:05 opsysdebug