RFR: 8264752: JFR crash when only specify threadbuffersize=30M

Hui Shi hshi at openjdk.java.net
Tue Apr 6 13:37:46 UTC 2021


SIGFPE crash happens in release build with following JFR crash options. Because div_total_by_per_unit try to divide smaller memorysize with larger threadbuffersize. 
div_total_by_per_unit
  const julong units = total_pages / per_unit_pages;    // units is zero
  const julong rem = total_pages % per_unit_pages;

  assert(units > 0, "invariant");

  if (rem > 0) {
    total_pages -= rem % units;
    per_unit_pages += rem / units;     // SIGFPE happen
  }

-XX:StartFlightRecording -XX:FlightRecorderOptions:threadbuffersize=30M
-XX:StartFlightRecording -XX:FlightRecorderOptions:threadbuffersize=30M,memorysize=10M

Fix includes
1. if threadbuffersize is larger than memorysize, fail with message
[0.019s][error][arguments] Value specified for option "memorysize" is 10M
[0.019s][error][arguments] Value specified for option "threadbuffersize" is 30M
[0.019s][error][arguments] The value for option "threadbuffersize" should not be larger than the value specified for option "memorysize
2. In "thread_buffer_size(JfrMemoryOptions* options)", If memor_size is not configured, calculate new memory_size according to buffer_size and buffer_count. Avoid possible SIGFPE in div_total_by_per_unit.


There are other assertions in debug build with JFR options, leave them in other bug fix (https://bugs.openjdk.java.net/browse/JDK-8241773) 
1. -XX:FlightRecorderOptions:threadbuffersize=6M,memorysize=10M    assert(options.buffer_count >= MIN_BUFFER_COUNT) failed: invariant 
2. -XX:FlightRecorderOptions:globalbuffersize=4G   assert(free_size() == size) failed: invariant  
3. -XX:FlightRecorderOptions:threadbuffersize=4G    assert(free_size() == size) failed: invariant

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

Commit messages:
 - 8264752: JFR crash when only specify threadbuffersize=30M

Changes: https://git.openjdk.java.net/jdk/pull/3355/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=3355&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8264752
  Stats: 16 lines in 3 files changed: 14 ins; 0 del; 2 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3355.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3355/head:pull/3355

PR: https://git.openjdk.java.net/jdk/pull/3355


More information about the hotspot-jfr-dev mailing list