Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8258954

CGroups - invalid detection of cgroupv2

XMLWordPrintable

    • x86_64
    • linux_ubuntu

      ADDITIONAL SYSTEM INFORMATION :
      Content of /proc/self/mountinfo
      16 21 0:15 / /sys rw,nosuid,nodev,noexec,relatime - sysfs sysfs rw
      17 21 0:3 / /proc rw,nosuid,nodev,noexec,relatime - proc proc rw
      18 21 0:5 / /dev rw,relatime - devtmpfs udev rw,size=8206048k,nr_inodes=2051512,mode=755
      19 18 0:12 / /dev/pts rw,nosuid,noexec,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000
      20 21 0:16 / /run rw,nosuid,noexec,relatime - tmpfs tmpfs rw,size=1643364k,mode=755
      21 0 8:5 / / rw,relatime - ext4 /dev/disk/by-uuid/812d6452-9193-4e6d-a9fd-259061b14840 rw,errors=remount-ro,data=ordered
      23 16 0:17 / /sys/fs/cgroup rw,relatime - tmpfs none rw,size=4k,mode=755
      24 16 0:18 / /sys/fs/fuse/connections rw,relatime - fusectl none rw
      25 16 0:6 / /sys/kernel/debug rw,relatime - debugfs none rw
      26 16 0:10 / /sys/kernel/security rw,relatime - securityfs none rw
      27 20 0:19 / /run/lock rw,nosuid,nodev,noexec,relatime - tmpfs none rw,size=5120k
      28 20 0:20 / /run/shm rw,nosuid,nodev,relatime - tmpfs none rw
      29 20 0:21 / /run/user rw,nosuid,nodev,noexec,relatime - tmpfs none rw,size=102400k,mode=755
      30 16 0:22 / /sys/fs/pstore rw,relatime - pstore none rw
      31 21 8:17 / /opt rw,relatime - ext4 /dev/sdb1 rw,data=ordered
      33 23 0:24 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime - cgroup systemd rw,name=systemd

      content of /proc/cgroups
      #subsys_name hierarchy num_cgroups enabled
      cpuset 0 1 1
      cpu 0 1 1
      cpuacct 0 1 1
      memory 0 1 1
      devices 0 1 1
      freezer 0 1 1
      net_cls 0 1 1
      blkio 0 1 1
      perf_event 0 1 1
      net_prio 0 1 1
      hugetlb 0 1 1



      A DESCRIPTION OF THE PROBLEM :
      I receive exception on my linux server

      Exception in thread "main" java.lang.InternalError: java.lang.reflect.InvocationTargetException
              at java.base/jdk.internal.platform.Metrics.systemMetrics(Metrics.java:65)
              at java.base/jdk.internal.platform.Container.metrics(Container.java:43)
              at jdk.management/com.sun.management.internal.OperatingSystemImpl.<init>(OperatingSystemImpl.java:48)
              at jdk.management/com.sun.management.internal.PlatformMBeanProviderImpl.getOperatingSystemMXBean(PlatformMBeanProviderImpl.java:281)
              at jdk.management/com.sun.management.internal.PlatformMBeanProviderImpl$3.nameToMBeanMap(PlatformMBeanProviderImpl.java:198)
              at java.management/sun.management.spi.PlatformMBeanProvider$PlatformComponent.getMBeans(PlatformMBeanProvider.java:195)
              at java.management/java.lang.management.ManagementFactory.getPlatformMXBean(ManagementFactory.java:686)
              at java.management/java.lang.management.ManagementFactory.getOperatingSystemMXBean(ManagementFactory.java:388)
              at testj15.Main.main(Main.java:9)
      Caused by: java.lang.reflect.InvocationTargetException
              at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
              at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.base/java.lang.reflect.Method.invoke(Method.java:564)
              at java.base/jdk.internal.platform.Metrics.systemMetrics(Metrics.java:61)
              ... 8 more
      Caused by: java.lang.ExceptionInInitializerError
              at java.base/jdk.internal.platform.CgroupSubsystemFactory.create(CgroupSubsystemFactory.java:77)
              at java.base/jdk.internal.platform.CgroupMetrics.getInstance(CgroupMetrics.java:163)
              ... 13 more
      Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 4 out of bounds for length 1
              at java.base/jdk.internal.platform.cgroupv2.CgroupV2Subsystem.initSubsystem(CgroupV2Subsystem.java:71)
              at java.base/jdk.internal.platform.cgroupv2.CgroupV2Subsystem.<clinit>(CgroupV2Subsystem.java:42)
              ... 15 more

      After checking for it I found than invalid version of cgroup was detected.
      This issue referenced to JDK-8239559

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create test project with Main-file
      public static void main(String[] args) throws Exception {
      ManagementFactory.getOperatingSystemMXBean();
      }

      2. Create file mountinfo with content
      16 21 0:15 / /sys rw,nosuid,nodev,noexec,relatime - sysfs sysfs rw
      17 21 0:3 / /proc rw,nosuid,nodev,noexec,relatime - proc proc rw
      18 21 0:5 / /dev rw,relatime - devtmpfs udev rw,size=8206048k,nr_inodes=2051512,mode=755
      19 18 0:12 / /dev/pts rw,nosuid,noexec,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000
      20 21 0:16 / /run rw,nosuid,noexec,relatime - tmpfs tmpfs rw,size=1643364k,mode=755
      21 0 8:5 / / rw,relatime - ext4 /dev/disk/by-uuid/812d6452-9193-4e6d-a9fd-259061b14840 rw,errors=remount-ro,data=ordered
      23 16 0:17 / /sys/fs/cgroup rw,relatime - tmpfs none rw,size=4k,mode=755
      24 16 0:18 / /sys/fs/fuse/connections rw,relatime - fusectl none rw
      25 16 0:6 / /sys/kernel/debug rw,relatime - debugfs none rw
      26 16 0:10 / /sys/kernel/security rw,relatime - securityfs none rw
      27 20 0:19 / /run/lock rw,nosuid,nodev,noexec,relatime - tmpfs none rw,size=5120k
      28 20 0:20 / /run/shm rw,nosuid,nodev,relatime - tmpfs none rw
      29 20 0:21 / /run/user rw,nosuid,nodev,noexec,relatime - tmpfs none rw,size=102400k,mode=755
      30 16 0:22 / /sys/fs/pstore rw,relatime - pstore none rw
      31 21 8:17 / /opt rw,relatime - ext4 /dev/sdb1 rw,data=ordered
      33 23 0:24 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime - cgroup systemd rw,name=systemd

      3. create file cgroup with content
       #subsys_name hierarchy num_cgroups enabled
      cpuset 0 1 1
      cpu 0 1 1
      cpuacct 0 1 1
      memory 0 1 1
      devices 0 1 1
      freezer 0 1 1
      net_cls 0 1 1
      blkio 0 1 1
      perf_event 0 1 1
      net_prio 0 1 1
      hugetlb 0 1 1

      4. Setup 2 breakpoints:
      4.1 jdk.internal.platform.CgroupSubsystemFactory:86
      Map<String, CgroupInfo> infos = new HashMap<>();

      4.2 jdk.internal.platform.cgroupv2.CgroupV2Subsystem:64
              String mountPath = null;

      5. Run test project under debug.
      When debugger stopped on breakpoint 4.1, replace variable values:
      5.1 write file path of mountinfo, created on step 2 to variable
      String mountInfo - jdk.internal.platform.CgroupSubsystemFactory.determineType(String, String)

      5.2 write file path of cgroup, created on step 3 to variable
      String cgroups - jdk.internal.platform.CgroupSubsystemFactory.determineType(String, String)

      6. Continue program execution. It will stopped on second break point.

      7. Press 2-3 times Step-Into until you will enter to java.nio.file.Paths:69

      8. Replace variable value:
      write file path of mountinfo, created on step 2 to variable
      String first - java.nio.file.Paths.get(String first, String... more)

      9. Continue program execution.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Program executed successfully.
      ACTUAL -
      Raised exception with stack trace

      Exception in thread "main" java.lang.InternalError: java.lang.reflect.InvocationTargetException
      at java.base/jdk.internal.platform.Metrics.systemMetrics(Metrics.java:65)
      at java.base/jdk.internal.platform.Container.metrics(Container.java:43)
      at jdk.management/com.sun.management.internal.OperatingSystemImpl.<init>(OperatingSystemImpl.java:48)
      at jdk.management/com.sun.management.internal.PlatformMBeanProviderImpl.getOperatingSystemMXBean(PlatformMBeanProviderImpl.java:281)
      at jdk.management/com.sun.management.internal.PlatformMBeanProviderImpl$3.nameToMBeanMap(PlatformMBeanProviderImpl.java:198)
      at java.management/sun.management.spi.PlatformMBeanProvider$PlatformComponent.getMBeans(PlatformMBeanProvider.java:195)
      at java.management/java.lang.management.ManagementFactory.getPlatformMXBean(ManagementFactory.java:686)
      at java.management/java.lang.management.ManagementFactory.getOperatingSystemMXBean(ManagementFactory.java:388)
      at testj15.Main.main(Main.java:7)
      Caused by: java.lang.reflect.InvocationTargetException
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:564)
      at java.base/jdk.internal.platform.Metrics.systemMetrics(Metrics.java:61)
      ... 8 more
      Caused by: java.lang.ExceptionInInitializerError
      at java.base/jdk.internal.platform.CgroupSubsystemFactory.create(CgroupSubsystemFactory.java:77)
      at java.base/jdk.internal.platform.CgroupMetrics.getInstance(CgroupMetrics.java:163)
      ... 13 more
      Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 4 out of bounds for length 1
      at java.base/jdk.internal.platform.cgroupv2.CgroupV2Subsystem.initSubsystem(CgroupV2Subsystem.java:71)
      at java.base/jdk.internal.platform.cgroupv2.CgroupV2Subsystem.<clinit>(CgroupV2Subsystem.java:42)
      ... 15 more


      ---------- BEGIN SOURCE ----------
      package testj15;

      import java.lang.management.ManagementFactory;

      public class Main {
      public static void main(String[] args) throws Exception {
      ManagementFactory.getOperatingSystemMXBean();
      }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      No workaround found at this moment

      FREQUENCY : always


        1. mountinfo
          1 kB
        2. mountinfo
          1 kB
        3. Main.java
          0.2 kB
        4. cgroups
          0.2 kB
        5. cgroup
          0.2 kB

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: