RFR: 8339648: ZGC: Division by zero in rule_major_allocation_rate [v2]
Lutz Schmidt
lucy at openjdk.org
Mon Sep 16 08:18:07 UTC 2024
On Mon, 9 Sep 2024 11:37:41 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:
>> The HS jtreg test gc/stringdedup/TestStringDeduplicationAgeThreshold_ZGenerational
>> shows this error when running with ubsan enabled
>>
>> src/hotspot/share/gc/z/zDirector.cpp:491:74: runtime error: division by zero
>> #0 0x7f09886401d4 in rule_major_allocation_rate src/hotspot/share/gc/z/zDirector.cpp:491
>> #1 0x7f09886401d4 in start_gc src/hotspot/share/gc/z/zDirector.cpp:822
>> #2 0x7f09886401d4 in ZDirector::run_thread() src/hotspot/share/gc/z/zDirector.cpp:912
>> #3 0x7f098c1404e8 in ZThread::run_service() src/hotspot/share/gc/z/zThread.cpp:29
>> #4 0x7f09897cac19 in ConcurrentGCThread::run() src/hotspot/share/gc/shared/concurrentGCThread.cpp:48
>> #5 0x7f098bb46b0a in Thread::call_run() src/hotspot/share/runtime/thread.cpp:225
>> #6 0x7f098b1a9881 in thread_native_entry src/hotspot/os/linux/os_linux.cpp:858
>
> Matthias Baesken has updated the pull request incrementally with one additional commit since the last revision:
>
> Adjust division following suggestion by xmas
Changes requested by lucy (Reviewer).
src/hotspot/share/gc/z/zDirector.cpp line 491:
> 489: // Calculate the GC cost for each reclaimed byte
> 490: const double current_young_gc_time_per_bytes_freed = double(young_gc_time) / double(reclaimed_per_young_gc);
> 491: const double current_old_gc_time_per_bytes_freed = reclaimed_per_old_gc == 0 ? std::numeric_limits<double>::infinity() : double(old_gc_time) / double(reclaimed_per_old_gc);
How about using some parentheses? To my understanding, the division has a higher precedence than the ternary conditional expression. See: https://en.cppreference.com/w/cpp/language/operator_precedence
-------------
PR Review: https://git.openjdk.org/jdk/pull/20888#pullrequestreview-2306000198
PR Review Comment: https://git.openjdk.org/jdk/pull/20888#discussion_r1760715673
More information about the hotspot-gc-dev
mailing list