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

[24.1] imageio AWT tests fail with JDK 23 ea #262

Closed
jerboaa opened this issue Jun 26, 2024 · 20 comments · Fixed by #277
Closed

[24.1] imageio AWT tests fail with JDK 23 ea #262

jerboaa opened this issue Jun 26, 2024 · 20 comments · Fixed by #277
Assignees
Labels
bug Something isn't working

Comments

@jerboaa
Copy link
Collaborator

jerboaa commented Jun 26, 2024

The imageio AWT integration tests seem to fail a JDK 23-based Mandrel 24.1 build with:

[...]
[INFO] --- shade:2.4.3:shade (default) @ imageio ---
[WARNING] Parameter 'localRepository' is deprecated core expression; Avoid use of ArtifactRepository type. If you need access to local repository, switch to '${repositorySystemSession}' expression and get LRM from it instead.
[INFO] Including org.jfree:org.jfree.svg:jar:4.1 in the shaded jar.
[INFO] Including org.jfree:jfreechart:jar:1.5.2 in the shaded jar.
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/target/imageio.jar with /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/target/imageio-1-shaded.jar
[INFO] Dependency-reduced POM written at: /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/dependency-reduced-pom.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.804 s
[INFO] Finished at: 2024-06-26T15:07:24+02:00
[INFO] ------------------------------------------------------------------------
2024-06-26 15:07:24.284 INFO  [o.g.t.i.u.Commands$ProcessRunner] (run) Command: [java, -Djava.awt.headless=true, -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image, -jar, target/imageio.jar]
2024-06-26 15:07:26.031 INFO  [o.g.t.i.u.Commands$ProcessRunner] (run) Command: [jar, uf, target/imageio.jar, -C, src/main/resources/, META-INF]
2024-06-26 15:07:26.361 INFO  [o.g.t.i.u.Commands$ProcessRunner] (run) Command: [native-image, -J-Djava.awt.headless=true, --no-fallback, -jar, target/imageio.jar, target/imageio]
Warning: Option 'DynamicProxyConfigurationResources' is deprecated and might be removed in a future release. Please refer to the GraalVM release notes.
========================================================================================================================
GraalVM Native Image: Generating 'imageio' (executable)...
========================================================================================================================
For detailed information and explanations on the build output, visit:
https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md
------------------------------------------------------------------------------------------------------------------------
[1/8] Initializing...                                                                                    (3.0s @ 0.16GB)
 Java version: 23-beta+28-202406240955, vendor version: Mandrel-24.1.0-dev22e2e94bb8f2
 Graal compiler: optimization level: 2, target machine: x86-64-v3
 C compiler: gcc (redhat, x86_64, 13.3.1)
 Garbage collector: Serial GC (max heap size: 80% of RAM)
 1 user-specific feature(s):
 - com.oracle.svm.thirdparty.gson.GsonFeature
------------------------------------------------------------------------------------------------------------------------
Build resources:
 - 26.49GB of memory (42.4% of 62.55GB system memory, determined at start)
 - 12 thread(s) (100.0% of 12 available processor(s), determined at start)
[2/8] Performing analysis...  [****]                                                                    (12.6s @ 0.57GB)
    5,798 reachable types   (75.9% of    7,644 total)
    9,530 reachable fields  (49.7% of   19,176 total)
   29,244 reachable methods (50.9% of   57,414 total)
    1,783 types,    79 fields, and   776 methods registered for reflection
       58 types,    58 fields, and    52 methods registered for JNI access
        4 native libraries: dl, pthread, rt, z
[3/8] Building universe...                                                                               (2.0s @ 0.65GB)
[4/8] Parsing methods...      [*]                                                                        (1.6s @ 0.44GB)
[5/8] Inlining methods...     [***]                                                                      (1.3s @ 0.52GB)
[6/8] Compiling methods...    [****]                                                                    (13.7s @ 0.77GB)
[7/8] Laying out methods...   [**]                                                                       (2.9s @ 0.96GB)
[8/8] Creating image...       [**]                                                                       (2.5s @ 1.12GB)
  13.02MB (46.83%) for code area:    17,964 compilation units
  14.20MB (51.09%) for image heap:  164,395 objects and 58 resources
 593.18kB ( 2.08%) for other data
  27.80MB in total
------------------------------------------------------------------------------------------------------------------------
Top 10 origins of code area:                                Top 10 object types in image heap:
   6.12MB java.base                                            3.41MB byte[] for code metadata
   5.27MB java.desktop                                         2.16MB byte[] for java.lang.String
   1.07MB svm.jar (Native Image)                               1.62MB java.lang.String
 116.92kB java.logging                                         1.36MB java.lang.Class
  67.01kB org.graalvm.nativeimage.base                         1.19MB byte[] for embedded resources
  49.32kB java.datatransfer                                  498.27kB com.oracle.svm.core.hub.DynamicHubCompanion
  48.63kB jdk.proxy2                                         359.67kB java.util.HashMap$Node
  43.31kB imageio.jar                                        325.87kB java.lang.String[]
  42.34kB jdk.proxy1                                         300.65kB byte[] for general heap data
  26.56kB jdk.internal.vm.ci                                 297.81kB byte[] for reflection metadata
  41.84kB for 6 more packages                                  2.72MB for 1215 more object types
------------------------------------------------------------------------------------------------------------------------
Recommendations:
 AWT:  Use the tracing agent to collect metadata for AWT.
 HEAP: Set max heap for improved and more predictable memory usage.
 CPU:  Enable more CPU features with '-march=native' for improved performance.
------------------------------------------------------------------------------------------------------------------------
                        1.8s (4.3% of total time) in 356 GCs | Peak RSS: 1.62GB | CPU load: 9.35
------------------------------------------------------------------------------------------------------------------------
Build artifacts:
 /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/target/imageio (executable)
 /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/target/libawt.so (jdk_library)
 /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/target/libawt_headless.so (jdk_library)
 /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/target/libawt_xawt.so (jdk_library)
 /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/target/libfontmanager.so (jdk_library)
 /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/target/libfreetype.so (jdk_library)
 /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/target/libjava.so (jdk_library_shim)
 /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/target/libjavajpeg.so (jdk_library)
 /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/target/libjvm.so (jdk_library_shim)
 /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/target/liblcms.so (jdk_library)
========================================================================================================================
Finished generating 'imageio' in 40.6s.
2024-06-26 15:08:08.376 INFO  [o.g.t.i.AppReproducersTest] (imageioAWT) Running...
2024-06-26 15:08:09.381 INFO  [o.g.t.i.u.Commands] (runCommand) Command: [./target/imageio, -Djava.home=., -Djava.awt.headless=true]
2024-06-26 15:08:09.424 INFO  [o.g.t.i.u.Commands] (pidKiller) Killing PID: 109047, forcefully: true
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 48.851 s <<< FAILURE! - in org.graalvm.tests.integration.AppReproducersTest
[ERROR] imageioAWTTest{TestInfo}  Time elapsed: 47.981 s  <<< FAILURE!
org.opentest4j.AssertionFailedError: 
There were errors checking the generated image files, see:
mytest.jpg was not generated.
mytest_toL.png was not generated.
mytest.bmp was not generated.
mytest_toG.png was not generated.
mytest.gif was not generated.
mytest.svg was not generated.
mytest.png was not generated.
mytest.tiff was not generated.
mytest_Resized_Grace_M._Hopper.png was not generated.
mytest_toC.png was not generated.
mytest_toP.png was not generated.
mytest.wbmp was not generated.
mytest_toS.png was not generated. ==> expected: <true> but was: <false>
	at org.graalvm.tests.integration.AppReproducersTest.imageioAWT(AppReproducersTest.java:607)
	at org.graalvm.tests.integration.AppReproducersTest.imageioAWTTest(AppReproducersTest.java:501)

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Failures: 
[ERROR]   AppReproducersTest.imageioAWTTest:501->imageioAWT:607 There were errors checking the generated image files, see:
mytest.jpg was not generated.
mytest_toL.png was not generated.
mytest.bmp was not generated.
mytest_toG.png was not generated.
mytest.gif was not generated.
mytest.svg was not generated.
mytest.png was not generated.
mytest.tiff was not generated.
mytest_Resized_Grace_M._Hopper.png was not generated.
mytest_toC.png was not generated.
mytest_toP.png was not generated.
mytest.wbmp was not generated.
mytest_toS.png was not generated. ==> expected: <true> but was: <false>
[INFO] 
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Native image integration TS 1.0.0-SNAPSHOT:
[INFO] 
[INFO] Native image integration TS ........................ SUCCESS [  0.104 s]
[INFO] testsuite .......................................... FAILURE [ 51.810 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  51.982 s
[INFO] Finished at: 2024-06-26T15:08:09+02:00
[INFO] ------------------------------------------------------------------------

Steps to reproduce

export JAVA_HOME=/path/to/mandrel-24.1
export GRAALVM_HOME=$JAVA_HOME
export PATH=$JAVA_HOME/bin:$PATH
mvn clean verify -Dquarkus.version=999-SNAPSHOT -Ptestsuite -Dtest=AppReproducersTest#imageioAWTTest
@jerboaa
Copy link
Collaborator Author

jerboaa commented Jun 26, 2024

/cc @Karm

@jerboaa
Copy link
Collaborator Author

jerboaa commented Jul 5, 2024

The test also fails on JDK 24 based Mandrel, fwiw:

========================================================================================================================
GraalVM Native Image: Generating 'imageio' (executable)...
========================================================================================================================
For detailed information and explanations on the build output, visit:
https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md
------------------------------------------------------------------------------------------------------------------------
[1/8] Initializing...                                                                                    (2.9s @ 0.17GB)
 Java version: 24-beta+4-ea, vendor version: Mandrel-24.2.0-devbb7f14ee3621
 Graal compiler: optimization level: 2, target machine: x86-64-v3
 C compiler: gcc (redhat, x86_64, 13.3.1)
 Garbage collector: Serial GC (max heap size: 80% of RAM)
 1 user-specific feature(s):
 - com.oracle.svm.thirdparty.gson.GsonFeature
------------------------------------------------------------------------------------------------------------------------
Build resources:
 - 26.49GB of memory (42.4% of 62.55GB system memory, determined at start)
 - 12 thread(s) (100.0% of 12 available processor(s), determined at start)
[2/8] Performing analysis...  [****]                                                                    (12.4s @ 0.60GB)
    5,806 reachable types   (75.5% of    7,686 total)
    9,529 reachable fields  (49.6% of   19,225 total)
   29,317 reachable methods (50.4% of   58,121 total)
    1,788 types,    79 fields, and   776 methods registered for reflection
       58 types,    58 fields, and    52 methods registered for JNI access
        4 native libraries: dl, pthread, rt, z
[3/8] Building universe...                                                                               (2.4s @ 0.68GB)
[4/8] Parsing methods...      [*]                                                                        (1.7s @ 0.39GB)
[5/8] Inlining methods...     [***]                                                                      (1.1s @ 0.48GB)
[6/8] Compiling methods...    [****]                                                                    (14.5s @ 0.77GB)
[7/8] Laying out methods...   [**]                                                                       (2.7s @ 0.95GB)
[8/8] Creating image...       [**]                                                                       (2.4s @ 1.10GB)
  13.40MB (47.50%) for code area:    18,001 compilation units
  14.23MB (50.45%) for image heap:  164,724 objects and 58 resources
 592.98kB ( 2.05%) for other data
  28.20MB in total
------------------------------------------------------------------------------------------------------------------------
Top 10 origins of code area:                                Top 10 object types in image heap:
   6.25MB java.base                                            3.44MB byte[] for code metadata
   5.34MB java.desktop                                         2.16MB byte[] for java.lang.String
   1.24MB svm.jar (Native Image)                               1.63MB java.lang.String
 119.36kB java.logging                                         1.36MB java.lang.Class
  69.38kB org.graalvm.nativeimage.base                         1.19MB byte[] for embedded resources
  50.46kB java.datatransfer                                  498.95kB com.oracle.svm.core.hub.DynamicHubCompanion
  49.71kB jdk.proxy2                                         360.19kB java.util.HashMap$Node
  43.99kB imageio.jar                                        326.57kB java.lang.String[]
  43.30kB jdk.proxy1                                         300.67kB byte[] for general heap data
  27.31kB jdk.internal.vm.ci                                 298.55kB byte[] for reflection metadata
  42.62kB for 6 more packages                                  2.70MB for 1218 more object types
------------------------------------------------------------------------------------------------------------------------
Recommendations:
 AWT:  Use the tracing agent to collect metadata for AWT.
 HEAP: Set max heap for improved and more predictable memory usage.
 CPU:  Enable more CPU features with '-march=native' for improved performance.
------------------------------------------------------------------------------------------------------------------------
                        1.9s (4.5% of total time) in 378 GCs | Peak RSS: 1.57GB | CPU load: 9.23
------------------------------------------------------------------------------------------------------------------------
Build artifacts:
 /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/target/imageio (executable)
 /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/target/libawt.so (jdk_library)
 /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/target/libawt_headless.so (jdk_library)
 /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/target/libawt_xawt.so (jdk_library)
 /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/target/libfontmanager.so (jdk_library)
 /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/target/libfreetype.so (jdk_library)
 /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/target/libjava.so (jdk_library_shim)
 /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/target/libjavajpeg.so (jdk_library)
 /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/target/libjvm.so (jdk_library_shim)
 /disk/graal/upstream-sources/mandrel-integration-tests/apps/imageio/target/liblcms.so (jdk_library)
========================================================================================================================
Finished generating 'imageio' in 41.2s.
2024-07-05 09:16:45.260 INFO  [o.g.t.i.AppReproducersTest] (imageioAWT) Running...
2024-07-05 09:16:46.265 INFO  [o.g.t.i.u.Commands] (runCommand) Command: [./target/imageio, -Djava.home=., -Djava.awt.headless=true]
2024-07-05 09:16:46.311 INFO  [o.g.t.i.u.Commands] (pidKiller) Killing PID: 33770, forcefully: true
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 49.723 s <<< FAILURE! - in org.graalvm.tests.integration.AppReproducersTest
[ERROR] imageioAWTTest{TestInfo}  Time elapsed: 48.849 s  <<< FAILURE!
org.opentest4j.AssertionFailedError: 
There were errors checking the generated image files, see:
mytest.jpg was not generated.
mytest_toL.png was not generated.
mytest.bmp was not generated.
mytest_toG.png was not generated.
mytest.gif was not generated.
mytest.svg was not generated.
mytest.png was not generated.
mytest.tiff was not generated.
mytest_Resized_Grace_M._Hopper.png was not generated.
mytest_toC.png was not generated.
mytest_toP.png was not generated.
mytest.wbmp was not generated.
mytest_toS.png was not generated. ==> expected: <true> but was: <false>
	at org.graalvm.tests.integration.AppReproducersTest.imageioAWT(AppReproducersTest.java:607)
	at org.graalvm.tests.integration.AppReproducersTest.imageioAWTTest(AppReproducersTest.java:501)

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Failures: 
[ERROR]   AppReproducersTest.imageioAWTTest:501->imageioAWT:607 There were errors checking the generated image files, see:
mytest.jpg was not generated.
mytest_toL.png was not generated.
mytest.bmp was not generated.
mytest_toG.png was not generated.
mytest.gif was not generated.
mytest.svg was not generated.
mytest.png was not generated.
mytest.tiff was not generated.
mytest_Resized_Grace_M._Hopper.png was not generated.
mytest_toC.png was not generated.
mytest_toP.png was not generated.
mytest.wbmp was not generated.
mytest_toS.png was not generated. ==> expected: <true> but was: <false>
[INFO] 
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------

@Karm
Copy link
Owner

Karm commented Jul 9, 2024

Taking a look now...

@jerboaa jerboaa added the bug Something isn't working label Jul 9, 2024
@jerboaa jerboaa added this to the Mandrel for JDK 23 milestone Jul 9, 2024
@Karm
Copy link
Owner

Karm commented Jul 9, 2024

@jerboaa

During the build, any specific way you are getting around this Vendor Version glitch in launcher? before I dive into those scripts of ours?

Both master+JDK24 and 24.1+JDK23:

[1/8] Initializing...                                                                                    (4.0s @ 0.17GB)
 Java version: 23-beta+30-ea, vendor version: Mandrel-WARNING: Could not parse jvmci version from JVMCIVersionCheck output:-Final
 Graal compiler: optimization level: 2, target machine: x86-64-v3

i.e. it bakes in the error output:

native-image --version
native-image 23-beta 2024-09-17
OpenJDK Runtime Environment Mandrel-WARNING: Could not parse jvmci version from JVMCIVersionCheck output:-Final (build 23-beta+30-ea)
OpenJDK 64-Bit Server VM Mandrel-WARNING: Could not parse jvmci version from JVMCIVersionCheck output:-Final (build 23-beta+30-ea, mixed mode)

@Karm
Copy link
Owner

Karm commented Jul 9, 2024

I am sorry, I have a mixup in JDK versions I think.

Mandrel 24.1 + JDK 23 build works for me on amd64:

 Java version: 23-beta+30-ea, vendor version: Mandrel-24.1.0.0-devc49fbc560ec

....but the same job fails on aarch64:

WARNING: No platform-specific definition is available for distribution MUSL_CMAKE_TOOLCHAIN for your architecture (aarch64)-Final

No need to stress I haven't changed anything in the way Adoptium API is queried, I'm not downloading musl versions....

@jerboaa
Copy link
Collaborator Author

jerboaa commented Jul 9, 2024

@Karm See graalvm/mandrel-packaging#429. For graal/master you need JDK 24. For mandrel/24.1 you'd need JDK 23.

I haven't seen the error that you see on aarch64, though (don't have such hardware handy).

@jerboaa
Copy link
Collaborator Author

jerboaa commented Jul 9, 2024

For 24.1: 23-beta+28 is known to work.
For 24.2: 24-beta+4 is known to work.

You might have to downgrade build JDK version.

@Karm
Copy link
Owner

Karm commented Jul 9, 2024

@jerboaa Both master + JDK 24 ea and 24.1 + JDK 23 ea builds work fine for me on Windows, Linux amd64 and Mac aarch64 now. The only weird quirk is Linux aarch64 with 24.1+JDK 23 ea, captured here: graalvm/mandrel#766

@jerboaa
Copy link
Collaborator Author

jerboaa commented Jul 10, 2024

Thanks!

@Karm
Copy link
Owner

Karm commented Jul 10, 2024

@jerboaa We have again the problem with loading awt so libs, I am looking deeper into it. And putting on TODO to modify this so as the error check happens sooner and makes sense in awt_LoadLibrary.c

149     jstring jbuf = JNU_NewStringPlatform(env, buf);
150     CHECK_EXCEPTION_FATAL(env, "Could not allocate library name");

The error happened before that, so the exception text is populated with "Could not allocate library name" but the NewString went just fine. The error was earlier and the message is misleading.

@jerboaa
Copy link
Collaborator Author

jerboaa commented Jul 10, 2024

@jerboaa We have again the problem with loading awt so libs

As in the "visibility hidden" problem to be fixed in OpenJDK?

@Karm
Copy link
Owner

Karm commented Jul 11, 2024

It's not that it seems :-/ Wip..

@Karm
Copy link
Owner

Karm commented Jul 12, 2024

@jerboaa @zakkak
Soo, I think there is a problem with the way the agent works.

When I manually babysit it and prepare correct jni-config.json by hand AND prepare fake JAVA_HOME as we had to do in Quarkus AND if I force the headless property on the executable at runtime, it works:

./target/imageio -Djava.awt.headless=true -Djava.home=/tmp/FAKE_JAVA_HOME

So it seems like -J-Djava.awt.headless=true for native-image command is not working nay more and that the agent also doesn' t generate acceptable config any more.

I will try to collect notes and prepare some more coherent report.

@jerboaa
Copy link
Collaborator Author

jerboaa commented Jul 12, 2024

Thanks!

@jerboaa
Copy link
Collaborator Author

jerboaa commented Jul 12, 2024

Upstream issue: oracle/graal#9300

Karm added a commit to Karm/jdk that referenced this issue Jul 13, 2024
If there is problem with finding and calling e.g. java/awt/GraphicsEnvironment
in AWTIsHeadless, the env' Exception remains set and it not cleared.
Later, that manifests as:

    Fatal error reported via JNI: Could not allocate library name

Which is misleading. The code path is perhaps rare in normal JDK usage,
but it has been complicating our users' bug reports in the GraalVM/native-image
ecosystem for quite some time.

Instead of failing later with some clear message that indicates that the
user has incorrectly configured JNI, it bails out very soon with a message
that seems as if a jstring could not have been allocated. It sends users
on wild goose chases, e.g.

oracle/graal#9138
oracle/graal#8475
oracle/graal#9300
quarkusio/quarkus#31596
graalvm/mandrel#292
Karm/mandrel-integration-tests#262

This commit fixes the error reporting in the AWTIsHeadless.

Furthermore, when AOT compiled, there is little sense for having a JAVA_HOME,
yet some parts of AWT code look for it to search fonts. In such case, an
empty directory structure is enough to accommodate it, e.g.

/tmp/JAVA_HOME/
/tmp/JAVA_HOME/conf
/tmp/JAVA_HOME/conf/fonts
/tmp/JAVA_HOME/lib

The exception is somewhat cryptic for users again, merely stating:

    Exception in thread "main" java.io.IOException: Problem reading font data.
        at java.desktop@22.0.1/java.awt.Font.createFont0(Font.java:1205)
        at java.desktop@22.0.1/java.awt.Font.createFont(Font.java:1076)
        at imageio.Main.loadFonts(Main.java:139

Adding the cause there makes it clearer, i.e. that JAVA_HOME might be missing:

    Exception in thread "main" java.io.IOException: Problem reading font data.
        at java.desktop@23-internal/java.awt.Font.createFont0(Font.java:1206)
        at java.desktop@23-internal/java.awt.Font.createFont(Font.java:1076)
        at imageio.Main.loadFonts(Main.java:139)
        at imageio.Main.paintRectangles(Main.java:97)
        at imageio.Main.main(Main.java:195)
        at java.base@23-internal/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
    Caused by: java.lang.Error: java.home property not set
        at java.desktop@23-internal/sun.awt.FontConfiguration.findFontConfigFile(FontConfiguration.java:180)
        at java.desktop@23-internal/sun.awt.FontConfiguration.<init>(FontConfiguration.java:97)
@jerboaa
Copy link
Collaborator Author

jerboaa commented Aug 13, 2024

@Karm Any update on this? The upstream graalvm issue I see is solved. Yet, we still see builds failing for example here: #266 (comment)

@Karm
Copy link
Owner

Karm commented Aug 13, 2024

Lemme check if it got integrated properly.

@Karm
Copy link
Owner

Karm commented Aug 15, 2024

@jerboaa It is broken again, i.e. Mandrel upstream build number 1430 worked, 1466 is broken. I'll take a look later today as to exactly why and whether it is a new issue or a regression of what was previously fixed.

@Karm
Copy link
Owner

Karm commented Aug 15, 2024

@jerboaa So, the timeline is that oracle/graal@71e6492 worked (as I note in the comment). Git bisect tells me that this is the first commit that broke it:

oracle/graal@fa89c6bf1ba6
I know, doesn't seem like it.
And yet, I had to switch JDKs during the bisect between Temurin-24+3-202406211439 and my homemade JDK24 56dec215b0d to make Mandrel build due to virtual threads, which is exactly what was oracle/graal@fa89c6bf1ba6 about.
All in all it's likely a change in JDK and not Graal that breaks it this time.
I've narrowed that to loadFonts and I'm gonna check what changed there in JDK.

@jerboaa
Copy link
Collaborator Author

jerboaa commented Aug 16, 2024

@jerboaa It is broken again, i.e. Mandrel upstream build number 1430 worked, 1466 is broken.

@Karm Do you have links to those builds?

I'll take a look later today as to exactly why and whether it is a new issue or a regression of what was previously fixed.

@Karm Do we need to backport oracle/graal@71e6492 to the 24.1 branch in order to fix imageio for that release? Something else?

Let's close this issue only when JDK 23 mandrel and JDK 24 mandrel are both fixed. Thanks!

@Karm Karm closed this as completed in #277 Aug 19, 2024
Karm added a commit to Karm/jdk that referenced this issue Nov 26, 2024
If there is problem with finding and calling e.g. java/awt/GraphicsEnvironment
in AWTIsHeadless, the env' Exception remains set and it not cleared.
Later, that manifests as:

    Fatal error reported via JNI: Could not allocate library name

Which is misleading. The code path is perhaps rare in normal JDK usage,
but it has been complicating our users' bug reports in the GraalVM/native-image
ecosystem for quite some time.

Instead of failing later with some clear message that indicates that the
user has incorrectly configured JNI, it bails out very soon with a message
that seems as if a jstring could not have been allocated. It sends users
on wild goose chases, e.g.

oracle/graal#9138
oracle/graal#8475
oracle/graal#9300
quarkusio/quarkus#31596
graalvm/mandrel#292
Karm/mandrel-integration-tests#262

This commit fixes the error reporting in the AWTIsHeadless.

Furthermore, when AOT compiled, there is little sense for having a JAVA_HOME,
yet some parts of AWT code look for it to search fonts. In such case, an
empty directory structure is enough to accommodate it, e.g.

/tmp/JAVA_HOME/
/tmp/JAVA_HOME/conf
/tmp/JAVA_HOME/conf/fonts
/tmp/JAVA_HOME/lib

The exception is somewhat cryptic for users again, merely stating:

    Exception in thread "main" java.io.IOException: Problem reading font data.
        at java.desktop@22.0.1/java.awt.Font.createFont0(Font.java:1205)
        at java.desktop@22.0.1/java.awt.Font.createFont(Font.java:1076)
        at imageio.Main.loadFonts(Main.java:139

Adding the cause there makes it clearer, i.e. that JAVA_HOME might be missing:

    Exception in thread "main" java.io.IOException: Problem reading font data.
        at java.desktop@23-internal/java.awt.Font.createFont0(Font.java:1206)
        at java.desktop@23-internal/java.awt.Font.createFont(Font.java:1076)
        at imageio.Main.loadFonts(Main.java:139)
        at imageio.Main.paintRectangles(Main.java:97)
        at imageio.Main.main(Main.java:195)
        at java.base@23-internal/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
    Caused by: java.lang.Error: java.home property not set
        at java.desktop@23-internal/sun.awt.FontConfiguration.findFontConfigFile(FontConfiguration.java:180)
        at java.desktop@23-internal/sun.awt.FontConfiguration.<init>(FontConfiguration.java:97)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants