RockteMQ-AI commented on issue #10674:
URL: https://github.com/apache/rocketmq/issues/10674#issuecomment-5112805124

   **Issue Evaluation**
   
   Category: `type/bug` | Status: **Confirmed**
   
   The reported integer overflow in three `long`-to-`int` comparators has been 
verified against the current `develop` branch codebase.
   
   **Affected locations:**
   1. `PopRequest.COMPARATOR` — `broker/.../longpolling/PopRequest.java:95,100` 
— `(int)(o1.getExpired() - o2.getExpired())` and `(int)(o1.op - o2.op)`
   2. `PopCheckPoint.compareTo` — `store/.../pop/PopCheckPoint.java:215` — 
`(int)(this.getStartOffset() - o.getStartOffset())`
   3. `PopReviveService.genSortList` — 
`broker/.../processor/PopReviveService.java:728` — `(int)(o1.getReviveOffset() 
- o2.getReviveOffset())`
   
   **Root Cause:** Subtracting two `long` values and casting the result to 
`int` overflows when the delta exceeds `Integer.MAX_VALUE`. This violates the 
`Comparator` / `Comparable` contract, which can corrupt `ConcurrentSkipListSet` 
invariants and sorted collection ordering.
   
   **Impact:** Pop long-polling request ordering, pop checkpoint sorting, pop 
revive service sorting — all production hot paths.
   
   **Severity:** High — silent data-structure corruption under normal broker 
operation (especially `PopRequest.op` counter starting at `Long.MIN_VALUE`).
   
   **Suggested fix:** Replace `(int)(a - b)` with `Long.compare(b, a)` (note 
reversed order for descending comparators where applicable).
   
   An automated fix proposal will be generated. Reply `/approve` to proceed 
with PR generation.
   
   ---
   *Automated evaluation by github-manager-bot*


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to