RFR: 8229147: Linux os::create_thread() overcounts guardpage size with newer glibc (>=2.27) [v2]
Aleksey Shipilev
shade at openjdk.org
Wed Apr 26 08:16:55 UTC 2023
On Sat, 22 Apr 2023 00:53:50 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> src/hotspot/os/linux/os_linux.cpp line 842:
>>
>>> 840: // If the minimum stack size changed when we added the guard pages
>>> 841: // then we need to perform the adjustment.
>>> 842: os::Linux::AdjustStackSizeForGuardPages = (min_stack2 - min_stack > 0);
>>
>> Subtracting the unsigned `size_t` is somewhat unsafe in face of underflows here. Just `min_stack2 > min_stack` solves it.
>
> Well I guess `minstack2 != minstack` suffices in that regard, but underflow is not a consideration here surely? If the difference was more than the specified guard size (modulo rounding) then there is a more serious glibc bug here.
Yes, just `!=` is fine as well. `-` would raise some eyebrows with static analyzers, I would have thought.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13571#discussion_r1177491999
More information about the hotspot-runtime-dev
mailing list