On Thu, 16 Apr 2026 13:32:05 GMT, Michael McMahon <[email protected]> wrote:
>> Hi, >> >> This is a small fix for j.l.ProcessHandle on MacOS. Unlike other platforms, >> Mac returns a ProcessHandle for pid 0 whose descendants are _all_ processes >> on the system. This specific scenario tickles an off by one error where the >> descendants method tries to access an element past the end of the array of >> pids. The fix is to break from the loop before accessing this element. >> >> Thanks, >> >> Michael >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > Michael McMahon has updated the pull request incrementally with one > additional commit since the last revision: > > updated impl and test src/java.base/share/classes/java/lang/ProcessHandleImpl.java line 466: > 464: ppid = pids[++count]; // pick up the next pid to scan for > 465: ppStart = starttimes[count]; // and its start time > 466: } while (count < next); Have you tried `} while (count < next && count < (size -1))` to avoid the break out of the loop. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/30763#discussion_r3094835751
