On Mon, 29 Jan 2024 17:45:34 GMT, Gerard Ziemski <gziem...@openjdk.org> wrote:
>> Hello Gerard, my understanding is that the limit value configured may exceed >> the int range. I wanted to avoid the overflow by casting it to int in such >> cases. I had noticed close() takes an int, but I couldn't think of any other >> way of avoiding the overflow at this place. >> >> In the JVM parent process we do however limit it to INT_MAX. So maybe I >> should assume that it will be an int cast it to int here, like you suggest, >> and add a code comment explaining this? Does that sound OK? > > That is fine, but in that case we should also do: > > `JDI_ASSERT(max_fd <= INT_MAX);` > > in case `sysconf(_SC_OPEN_MAX)` returns value greater than `INT_MAX`, since > `close()` only accepts `int`. Done. I've updated the PR to add this assert. Additionally I've also slightly changed the implementation in the newly introduced closeDescriptors() method to ensure that we don't pass values to close() that exceed INT_MAX. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/17588#discussion_r1471460024