RFR: 8336911: ZGC: Division by zero in heuristics after JDK-8332717

Matthias Baesken mbaesken at openjdk.org
Wed Oct 2 12:05:05 UTC 2024


When running with ubsan enabled binaries, the following issue is reported,
e.g. in test
compiler/uncommontrap/TestDeoptOOM_ZGenerational.jtr
also in gc/z/TestSmallHeap.jtr


jdk/src/hotspot/share/gc/z/zDirector.cpp:537:84: runtime error: division by zero
    #0 0x7f422495bd1f in calculate_young_to_old_worker_ratio src/hotspot/share/gc/z/zDirector.cpp:537
    #1 0x7f422495bd1f in select_worker_threads src/hotspot/share/gc/z/zDirector.cpp:694
    #2 0x7f42282a0d97 in select_worker_threads src/hotspot/share/gc/z/zDirector.cpp:689
    #3 0x7f42282a0d97 in initial_workers src/hotspot/share/gc/z/zDirector.cpp:784
    #4 0x7f42282a2485 in initial_workers src/hotspot/share/gc/z/zDirector.cpp:795
    #5 0x7f42282a2485 in start_minor_gc src/hotspot/share/gc/z/zDirector.cpp:797
    #6 0x7f42282a2485 in start_gc src/hotspot/share/gc/z/zDirector.cpp:826
    #7 0x7f42282a2485 in ZDirector::run_thread() src/hotspot/share/gc/z/zDirector.cpp:912
    #8 0x7f422840bdd8 in ZThread::run_service() src/hotspot/share/gc/z/zThread.cpp:29
    #9 0x7f4225ab6979 in ConcurrentGCThread::run() src/hotspot/share/gc/shared/concurrentGCThread.cpp:48
    #10 0x7f4227e1137a in Thread::call_run() src/hotspot/share/runtime/thread.cpp:225
    #11 0x7f42274619b1 in thread_native_entry src/hotspot/os/linux/os_linux.cpp:858
    #12 0x7f422c8d36e9 in start_thread (/lib64/libpthread.so.0+0xa6e9) (BuildId: 9a146bd267419cb6a8cf08d7c602953a0f2e12c5)
    #13 0x7f422c1dc58e in clone (/lib64/libc.so.6+0x11858e) (BuildId: f2d1cb1ef49f8c47d43a4053910ba6137673ccce)


The division by 0 leads to  'infinity'  on most of our platforms. So instead of relying on this behavior, we can add a small check and  set 'infinity'  for divisor == 0.

-------------

Commit messages:
 - JDK-8336911

Changes: https://git.openjdk.org/jdk/pull/21304/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=21304&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8336911
  Stats: 2 lines in 1 file changed: 1 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/21304.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/21304/head:pull/21304

PR: https://git.openjdk.org/jdk/pull/21304


More information about the hotspot-gc-dev mailing list