oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.39k stars 1.64k forks source link

native-image hangs in Linux but works in macOS and Windows #3042

Closed robby-phd closed 3 years ago

robby-phd commented 3 years ago

Describe the issue For a jar file from my project, native-image hangs in Linux but compiles successfully in macOS (and Windows).

Steps to reproduce the issue

curl -JLo sireum.jar http://pub.santoslab.org/sireum.jar
native-image --native-image-info --verbose --initialize-at-build-time --no-fallback --report-unsupported-elements-at-runtime -H:+ReportExceptionStackTraces -jar sireum.jar sireum

Describe GraalVM and your environment:

More details

It seems the issue is triggered from this line, which eventually calls Thread.join()/Object.wait().

Logs:

munishchouhan commented 3 years ago

@robby-phd Thanks for reporting the issue we will check it out and let you know our thoughts

christianwimmer commented 3 years ago

No idea what the class initializer

org.sireum.Os_Ext$.<clinit>

is doing. But definitely something that should not run at image build time. Why do you have --initialize-at-build-time on the native image command line? Unless you have manually inspected all classes to be safe for initialization at image build time, this is not an option to use.

robby-phd commented 3 years ago

I thought I did, but I changed a field initialization that used to be simple and forgot to make the modified unsafe-at-build-time initialization lazy. It is interesting that the problem only manifests in Linux. Anyway, I have made the field lazy and confirmed that it workarounds the issue. Thanks.

munishchouhan commented 3 years ago

as the issue has been resolved, closing the issue

robby-phd commented 3 years ago

It would be great if native-image behaves the same/similarly on the different platforms that it supports for the same input and options specified.

christianwimmer commented 3 years ago

It would be great if native-image behaves the same/similarly on the different platforms that it supports for the same input and options specified.

But in that case the application is behaving differently on the different platforms.

robby-phd commented 3 years ago

Ah yes, you are right. Just curious, will there be a feature to abort native compilation with --initialize-at-build-time when an init hits an unsafe method (and perhaps output a nice error message with the relevant call chain)?