[8u] RFR: 8187450: JNI local refs exceeds capacity warning in NetworkInterface::getAll

Hohensee, Paul hohensee at amazon.com
Tue Apr 27 20:32:56 UTC 2021


Lgtm.

Thanks,
Paul

-----Original Message-----
From: jdk8u-dev <jdk8u-dev-retn at openjdk.java.net> on behalf of Jonathan Dowland <jdowland at redhat.com>
Date: Thursday, March 25, 2021 at 2:59 AM
To: "jdk8u-dev at openjdk.java.net" <jdk8u-dev at openjdk.java.net>
Subject: [8u] RFR: 8187450: JNI local refs exceeds capacity warning in NetworkInterface::getAll

Good morning,

I'm requesting a review of a backport of JDK-8187450 to 8u.

The patch (from 11u backport) does not apply cleanly, just one hunk due
to extra #if defined(AF_INET6) in the context.

Bug: https://bugs.openjdk.java.net/browse/JDK-8187450
Webrev: https://cr.openjdk.java.net/~jdowland/webrevs/JDK-8187450/webrev.jdk8u.00/

Testing notes:

test/java/net/NetworkInterface/Test.java passes.

I had two tier1 failures that I am confident are unrelated, and also
fail for me against a known-good 8u:

    tools/javac/diags/CheckExamples.java: provide examples of code that generate diagnostics
    tools/javac/fatalErrors/NoJavaLangTest.java: Verify that the compiler does not crash when java.lang is not
they fail with jtreg

The rest of tier1 passed.

If you want to check out the impact this change makes, on a Linux host
you can use network namespaces to isolate the number of network
interfaces that are visible to Java, and steadily add more (virtual)
interfaces. There are some shell script snippets in the original GitHub
PR that might be useful:

    https://github.com/openjdk/jdk/pull/2963

My results comparing before/after this patch for 8u are

baseline, 2 network interfaces sufficient to breach the local refs limit:

    $ sudo ip netns exec jbase ip link show | grep UP | wc -l
     2
    $ sudo ip netns exec jbase $JAVA_HOME/bin/java -Xcheck:jni NITest
    WARNING: JNI local refs: 33, exceeds capacity: 32
        at java.net.NetworkInterface.getAll(Native Method)
        at java.net.NetworkInterface.getNetworkInterfaces(NetworkInterface.java:355)
        at NITest.main(NITest.java:4)

after patch, the first local refs breach occurs with 5 interfaces:

    ...
    $ ./addif.sh 4
    5 interfaces
    $ sudo ip netns exec jbase $JAVA_HOME/bin/java -Xcheck:jni NITest
    WARNING: JNI local refs: 33, exceeds capacity: 32
            at java.net.NetworkInterface.getAll(Native Method)
            at java.net.NetworkInterface.getNetworkInterfaces(NetworkInterface.java:355)
            at NITest.main(NITest.java:4)

after patch, it takes 10 interfaces to breach the next limit

    ...
    $ ./addif.sh 9
    10 interfaces
    $ sudo ip netns exec jbase $JAVA_HOME/bin/java -Xcheck:jni NITest
    WARNING: JNI local refs: 33, exceeds capacity: 32
            at java.net.NetworkInterface.getAll(Native Method)
            at java.net.NetworkInterface.getNetworkInterfaces(NetworkInterface.java:355)
            at NITest.main(NITest.java:4)
    WARNING: JNI local refs: 66, exceeds capacity: 65
            at java.net.NetworkInterface.getAll(Native Method)
            at java.net.NetworkInterface.getNetworkInterfaces(NetworkInterface.java:355)
            at NITest.main(NITest.java:4)


--
���� Jonathan Dowland <jdowland at redhat.com>
Senior Software Engineer, OpenJDK, Red Hat




More information about the jdk8u-dev mailing list