Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraalVM: Error with RunReachabilityHandlersConcurrently build argument #1344

Closed
ddobrin opened this issue Feb 9, 2023 · 10 comments
Closed
Assignees
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@ddobrin
Copy link

ddobrin commented Feb 9, 2023

In GraalVM, while upgrading to 22.2 the team had to disable concurrent reachability since it was causing some failures in the client libraries when building native images: Issue.

In GraalVM, latest versions (22.3.0 and 22.3.1), disabling the RunReachabilityHandlersConcurrently build argument introduces the need to add a number of additional dependencies (rome tools and kotlinx). GraalVM has it turned on by default.

The issue can be alleviated by reenabling the build argument in an application.
Reproducer: https://github.com/ddobrin/serverless-photosharing-workshop/tree/master/services/image-analysis/java

Tested with the latest BOM version as of today: 26.7.0.

            <plugin>
                <groupId>org.graalvm.buildtools</groupId>
                <artifactId>native-maven-plugin</artifactId>
                <configuration>
                    <buildArgs>
                        <arg>-H:+RunReachabilityHandlersConcurrently</arg>
                    </buildArgs>                
                </configuration>
            </plugin>  

The ask: Could the issue be re-validated in the client libraries with GraalVM 22.3.x to ascertain whether the flag is still creating an issue?

Thank you

@mpeddada1
Copy link
Contributor

Thank you for your investigation @ddobrin! Sharing some findings here after testing this out. Unfortunately, it appears that the issue persists when RunReachabilityHandlersConcurrently is enabled despite upgrading to 22.3.0 and 22.3.1 (https://github.com/mpeddada1/graalvm22.2-reachability#does-this-sample-work-without-the-workaround-in-graalvm-2231-latest)

===================================================================================
GraalVM Native Image: Generating 'native-tests' (executable)...
===================================================================================
[1/7] Initializing...                                               (5.1s @ 0.22GB)
 Version info: 'GraalVM 22.3.1 Java 11 CE'
 Java version info: '11.0.18+10-jvmci-22.3-b13'
 C compiler: gcc (linux, x86_64, 12.2.0)
 Garbage collector: Serial GC
 2 user-specific feature(s)
 - com.example.MyNativeImageFeature
 - org.graalvm.junit.platform.JUnitPlatformFeature
[junit-platform-native] Running in 'test listener' mode using files matching pattern [junit-platform-unique-ids*] found in folder [${HOME}/graalvm22.2-reachability/child-module/target/test-ids] and its subfolders.
[2/7] Performing analysis...  [******]                             (11.0s @ 1.58GB)
   4,363 (79.10%) of  5,516 classes reachable
   5,430 (58.46%) of  9,288 fields reachable
  19,097 (50.47%) of 37,835 methods reachable
     155 classes,     2 fields, and   545 methods registered for reflection
      58 classes,    58 fields, and    52 methods registered for JNI access
       4 native libraries: dl, pthread, rt, z
[3/7] Building universe...                                          (1.9s @ 0.85GB)
[4/7] Parsing methods...      [*]                                   (1.4s @ 1.92GB)
[5/7] Inlining methods...     [***]                                 (0.9s @ 2.53GB)
[6/7] Compiling methods...    [***]                                 (8.4s @ 1.52GB)
[7/7] Creating image...                                             (1.8s @ 2.11GB)
   6.23MB (37.56%) for code area:    11,308 compilation units
   9.52MB (57.38%) for image heap:  120,459 objects and 7 resources
 859.91KB ( 5.06%) for other data
  16.59MB in total
-----------------------------------------------------------------------------------
Top 10 packages in code area:            Top 10 object types in image heap:
 816.60KB java.util                         1.35MB byte[] for code metadata
 394.53KB com.sun.crypto.provider           1.11MB java.lang.String
 358.69KB java.lang                         1.02MB java.lang.Class
 284.24KB java.util.concurrent            977.52KB byte[] for general heap data
 224.78KB java.text                       824.72KB byte[] for java.lang.String
 207.10KB java.util.stream                410.53KB java.util.HashMap$Node
 205.18KB java.util.regex                 409.03KB c.o.s.c.h.DynamicHubCompanion
 183.88KB java.io                         231.64KB java.util.HashMap$Node[]
 162.89KB sun.security.provider           205.72KB java.lang.String[]
 154.35KB java.math                       195.61KB j.u.c.ConcurrentHashMap$Node
   3.22MB for 190 more packages             1.84MB for 1076 more object types
-----------------------------------------------------------------------------------
      1.1s (3.3% of total time) in 19 GCs | Peak RSS: 4.89GB | CPU load: 6.93
-----------------------------------------------------------------------------------
Produced artifacts:
${HOME}/graalvm22.2-reachability/child-module/target/native-tests (executable)
${HOME}/graalvm22.2-reachability/child-module/target/native-tests.build_artifacts.txt (txt)
===================================================================================
Finished generating 'native-tests' in 32.2s.
[INFO] Executing: ${HOME}/graalvm22.2-reachability/child-module/target/native-tests --xml-output-dir ${HOME}/graalvm22.2-reachability/child-module/target/native-test-reports -Djunit.platform.listeners.uid.tracking.output.dir=${HOME}/graalvm22.2-reachability/child-module/target/test-ids
JUnit Platform on Native Image - report
----------------------------------------

**********VALUE of USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM************
null
com.example.MySampleTest > testSample FAILED


Failures (1):
  JUnit Vintage:MySampleTest:testSample
    MethodSource [className = 'com.example.MySampleTest', methodName = 'testSample', methodParameterTypes = '']
    => java.lang.RuntimeException: Generated message class "com.example.MySampleClass" missing method "getName".
       com.anotherpackage.GeneratedMessage.retrieveMethod(GeneratedMessage.java:31)
       com.anotherpackage.GeneratedMessage.access$000(GeneratedMessage.java:5)
       com.anotherpackage.GeneratedMessage$MethodAccessor.<init>(GeneratedMessage.java:20)
       com.anotherpackage.GeneratedMessage$A.initializeMethodAccessor(GeneratedMessage.java:11)
       com.example.MySampleClass.invokeAccessor(MySampleClass.java:13)
       [...]
     Caused by: java.lang.NoSuchMethodException: com.example.MySampleClass.getName()
       java.base@11.0.18/java.lang.Class.getMethod(DynamicHub.java:2108)
       com.anotherpackage.GeneratedMessage.retrieveMethod(GeneratedMessage.java:28)
       [...]

I'm also able to reproduce the same issue when running tests in java-datatore ( mvn test -Dtest=com.google.cloud.datastore.admin.v1.DatastoreAdminClientTest -Pnative -DfailIfNoTests=false) locally with -H:+RunReachabilityHandlersConcurrently

@mpeddada1
Copy link
Contributor

From conversation in googleapis/gax-java#1815 (comment): The GraalVM team is tracking this issue(oracle/graal#5194) and will follow up on their findings. Will keep an eye on it in the meantime.

@mpeddada1 mpeddada1 added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Feb 16, 2023
@ddobrin
Copy link
Author

ddobrin commented Feb 16, 2023

Thanks for the update.
We'll see when the fix for oracle/graal#5868 is released.

@mpeddada1 mpeddada1 added priority: p3 Desirable enhancement or fix. May not be included in next release. and removed priority: p2 Moderately-important priority. Fix may not be included in next release. labels May 9, 2023
@mpeddada1
Copy link
Contributor

The fix for the original issue was merged and added as a milestone for the upcoming feature release - GraalVM for JDK 17 / JDK 20

@mpeddada1 mpeddada1 added priority: p2 Moderately-important priority. Fix may not be included in next release. and removed priority: p3 Desirable enhancement or fix. May not be included in next release. labels May 9, 2023
@zakkak
Copy link

zakkak commented Jun 29, 2023

FYI:

GraalVM for JDK 17 / JDK 20 is now released and includes the said fix.

I have also opened a backport PR to get the fix in 22.3.3 as well .

@mpeddada1
Copy link
Contributor

Thanks so much for the heads up and putting up the PR @zakkak!

@meltsufin meltsufin added priority: p3 Desirable enhancement or fix. May not be included in next release. and removed priority: p2 Moderately-important priority. Fix may not be included in next release. labels Aug 10, 2023
@zakkak
Copy link

zakkak commented Sep 7, 2023

GraalVM 22.3.3 is also released now, rendering -H:-RunReachabilityHandlersConcurrently unnecessary for GraalVM >= 22.3.3

@mpeddada1 is there anything preventing it's removal? What are the GraalVM versions that sdk-platform-java supports?

@mpeddada1
Copy link
Contributor

mpeddada1 commented Sep 7, 2023

Hi @zakkak, we've merged the PR that removes this argument: #1892. It will be included in release 2.25.0 of this repo.

@zakkak
Copy link

zakkak commented Sep 8, 2023

Great, thanks for the update @mpeddada1!

@mpeddada1
Copy link
Contributor

@zakkak @ddobrin Thanks for your patience. This change is now part of libraries-bom:26.23.0!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

4 participants