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.42k stars 1.64k forks source link

[Native Image] gcc: internal compiler error: Segmentation fault signal terminated program collect2 #9867

Closed bodiam closed 1 month ago

bodiam commented 1 month ago

Describe the Issue

I'm building a Kotlin hello world Spring Boot app (see attached). It's created using start.spring.io, using only the web and native dependencies.

When I run ./gradlew bootBuildImage, I'm getting a failed build.

native 2.zip

Using the latest version of GraalVM can resolve many issues.

GraalVM Version

I'm not entirely sure, I'm using the buildPacks

Operating System and Version

MacOS

Build Command

./gradlew bootBuildImage

Expected Behavior

Successful build

Actual Behavior

Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details

Task :bootBuildImage Building image 'docker.io/library/native:0.0.1-SNAPSHOT'

Pulling builder image 'docker.io/paketobuildpacks/builder-jammy-tiny:latest' .................................................. Pulled builder image 'paketobuildpacks/builder-jammy-tiny@sha256:7284020c89c52fbf97ddd11de1a41453d68e2a2c19c94e08d3018212d1ec930c' Pulling run image 'docker.io/paketobuildpacks/run-jammy-tiny:latest' .................................................. Pulled run image 'paketobuildpacks/run-jammy-tiny@sha256:402b925a81a4c6985438fd37d0b22022ca688e528bbd46a38831a3702067cced' Executing lifecycle version v0.20.3 Using build cache volume 'pack-cache-452943cd6171.build'

Running creator [creator] ===> ANALYZING [creator] Image with name "docker.io/library/native:0.0.1-SNAPSHOT" not found [creator] ===> DETECTING [creator] target distro name/version labels not found, reading /etc/os-release file [creator] 6 of 15 buildpacks participating [creator] paketo-buildpacks/ca-certificates 3.8.6 [creator] paketo-buildpacks/bellsoft-liberica 10.9.0 [creator] paketo-buildpacks/syft 2.1.0 [creator] paketo-buildpacks/executable-jar 6.11.3 [creator] paketo-buildpacks/spring-boot 5.31.2 [creator] paketo-buildpacks/native-image 5.14.4 [creator] ===> RESTORING [creator] ===> BUILDING [creator] target distro name/version labels not found, reading /etc/os-release file [creator] [creator] Paketo Buildpack for CA Certificates 3.8.6 [creator] https://github.com/paketo-buildpacks/ca-certificates [creator] Build Configuration: [creator] $BP_EMBED_CERTS false Embed certificates into the image [creator] $BP_ENABLE_RUNTIME_CERT_BINDING true Deprecated: Enable/disable certificate helper layer to add certs at runtime [creator] $BP_RUNTIME_CERT_BINDING_DISABLED false Disable certificate helper layer to add certs at runtime [creator] Launch Helper: Contributing to layer [creator] Creating /layers/paketo-buildpacks_ca-certificates/helper/exec.d/ca-certificates-helper [creator] [creator] Paketo Buildpack for BellSoft Liberica 10.9.0 [creator] https://github.com/paketo-buildpacks/bellsoft-liberica [creator] Build Configuration: [creator] $BP_JVM_JLINK_ARGS --no-man-pages --no-header-files --strip-debug --compress=1 configure custom link arguments (--output must be omitted) [creator] $BP_JVM_JLINK_ENABLED false enables running jlink tool to generate custom JRE [creator] $BP_JVM_TYPE JRE the JVM type - JDK or JRE [creator] $BP_JVM_VERSION 17 the Java version [creator] Launch Configuration: [creator] $BPL_DEBUG_ENABLED false enables Java remote debugging support [creator] $BPL_DEBUG_PORT 8000 configure the remote debugging port [creator] $BPL_DEBUG_SUSPEND false configure whether to suspend execution until a debugger has attached [creator] $BPL_HEAP_DUMP_PATH write heap dumps on error to this path [creator] $BPL_JAVA_NMT_ENABLED true enables Java Native Memory Tracking (NMT) [creator] $BPL_JAVA_NMT_LEVEL summary configure level of NMT, summary or detail [creator] $BPL_JFR_ARGS configure custom Java Flight Recording (JFR) arguments [creator] $BPL_JFR_ENABLED false enables Java Flight Recording (JFR) [creator] $BPL_JMX_ENABLED false enables Java Management Extensions (JMX) [creator] $BPL_JMX_PORT 5000 configure the JMX port [creator] $BPL_JVM_HEAD_ROOM 0 the headroom in memory calculation [creator] $BPL_JVM_LOADED_CLASS_COUNT 35% of classes the number of loaded classes in memory calculation [creator] $BPL_JVM_THREAD_COUNT 250 the number of threads in memory calculation [creator] $JAVA_TOOL_OPTIONS the JVM launch flags [creator] Using Java version 21 extracted from MANIFEST.MF [creator] BellSoft Liberica NIK 21.0.4: Contributing to layer [creator] Downloading from https://github.com/bell-sw/LibericaNIK/releases/download/23.1.4+3-21.0.4+9/bellsoft-liberica-vm-core-openjdk21.0.4+9-23.1.4+3-linux-amd64.tar.gz [creator] Verifying checksum [creator] Expanding to /layers/paketo-buildpacks_bellsoft-liberica/native-image-svm [creator] Adding 146 container CA certificates to JVM truststore [creator] Writing env.build/JAVA_HOME.override [creator] Writing env.build/JDK_HOME.override [creator] [creator] Paketo Buildpack for Syft 2.1.0 [creator] https://github.com/paketo-buildpacks/syft [creator] Downloading from https://github.com/anchore/syft/releases/download/v1.12.2/syft_1.12.2_linux_amd64.tar.gz [creator] Verifying checksum [creator] Writing env.build/SYFT_CHECK_FOR_APP_UPDATE.default [creator] [creator] Paketo Buildpack for Executable JAR 6.11.3 [creator] https://github.com/paketo-buildpacks/executable-jar [creator] Class Path: Contributing to layer [creator] Writing env/CLASSPATH.delim [creator] Writing env/CLASSPATH.prepend [creator] Process types: [creator] executable-jar: java org.springframework.boot.loader.launch.JarLauncher (direct) [creator] task: java org.springframework.boot.loader.launch.JarLauncher (direct) [creator] web: java org.springframework.boot.loader.launch.JarLauncher (direct) [creator] [creator] Paketo Buildpack for Spring Boot 5.31.2 [creator] https://github.com/paketo-buildpacks/spring-boot [creator] Build Configuration: [creator] $BPL_JVM_CDS_ENABLED false whether to enable CDS optimizations at runtime [creator] $BPL_SPRING_AOT_ENABLED false whether to enable Spring AOT at runtime [creator] $BP_JVM_CDS_ENABLED false whether to enable CDS & perform JVM training run [creator] $BP_SPRING_AOT_ENABLED false whether to enable Spring AOT [creator] $BP_SPRING_CLOUD_BINDINGS_DISABLED false whether to contribute Spring Boot cloud bindings support [creator] $BP_SPRING_CLOUD_BINDINGS_VERSION 1 default version of Spring Cloud Bindings library to contribute [creator] Launch Configuration: [creator] $BPL_SPRING_CLOUD_BINDINGS_DISABLED false whether to auto-configure Spring Boot environment properties from bindings [creator] $BPL_SPRING_CLOUD_BINDINGS_ENABLED true Deprecated - whether to auto-configure Spring Boot environment properties from bindings [creator] Class Path: Contributing to layer [creator] Writing env.build/CLASSPATH.append [creator] Writing env.build/CLASSPATH.delim [creator] Image labels: [creator] org.opencontainers.image.title [creator] org.opencontainers.image.version [creator] org.springframework.boot.version [creator] [creator] Paketo Buildpack for Native Image 5.14.4 [creator] https://github.com/paketo-buildpacks/native-image [creator] Build Configuration: [creator] $BP_BINARY_COMPRESSION_METHOD Compression mechanism used to reduce binary size. Options: none (default), upx or gzexe [creator] $BP_NATIVE_IMAGE true enable native image build [creator] $BP_NATIVE_IMAGE_BUILD_ARGUMENTS arguments to pass to the native-image command [creator] $BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE a file with arguments to pass to the native-image command [creator] $BP_NATIVE_IMAGE_BUILT_ARTIFACT the built application artifact explicitly, required if building from a JAR [creator] Native Image: Contributing to layer [creator] Executing native-image --no-fallback -H:+StaticExecutableWithDynamicLibC -H:Name=/layers/paketo-buildpacks_native-image/native-image/com.example.demo.NativeApplicationKt -cp /workspace:/workspace/BOOT-INF/classes:/workspace/BOOT-INF/lib/jackson-datatype-jdk8-2.17.2.jar:/workspace/BOOT-INF/lib/jackson-datatype-jsr310-2.17.2.jar:/workspace/BOOT-INF/lib/jackson-module-parameter-names-2.17.2.jar:/workspace/BOOT-INF/lib/jackson-databind-2.17.2.jar:/workspace/BOOT-INF/lib/jackson-annotations-2.17.2.jar:/workspace/BOOT-INF/lib/jackson-core-2.17.2.jar:/workspace/BOOT-INF/lib/jackson-module-kotlin-2.17.2.jar:/workspace/BOOT-INF/lib/kotlin-reflect-1.9.25.jar:/workspace/BOOT-INF/lib/kotlin-stdlib-1.9.25.jar:/workspace/BOOT-INF/lib/annotations-13.0.jar:/workspace/BOOT-INF/lib/spring-webmvc-6.1.13.jar:/workspace/BOOT-INF/lib/spring-web-6.1.13.jar:/workspace/BOOT-INF/lib/spring-boot-autoconfigure-3.3.4.jar:/workspace/BOOT-INF/lib/spring-boot-3.3.4.jar:/workspace/BOOT-INF/lib/jakarta.annotation-api-2.1.1.jar:/workspace/BOOT-INF/lib/spring-context-6.1.13.jar:/workspace/BOOT-INF/lib/spring-aop-6.1.13.jar:/workspace/BOOT-INF/lib/spring-beans-6.1.13.jar:/workspace/BOOT-INF/lib/spring-expression-6.1.13.jar:/workspace/BOOT-INF/lib/spring-core-6.1.13.jar:/workspace/BOOT-INF/lib/snakeyaml-2.2.jar:/workspace/BOOT-INF/lib/tomcat-embed-websocket-10.1.30.jar:/workspace/BOOT-INF/lib/tomcat-embed-core-10.1.30.jar:/workspace/BOOT-INF/lib/tomcat-embed-el-10.1.30.jar:/workspace/BOOT-INF/lib/micrometer-observation-1.13.4.jar:/workspace/BOOT-INF/lib/logback-classic-1.5.8.jar:/workspace/BOOT-INF/lib/log4j-to-slf4j-2.23.1.jar:/workspace/BOOT-INF/lib/jul-to-slf4j-2.0.16.jar:/workspace/BOOT-INF/lib/spring-jcl-6.1.13.jar:/workspace/BOOT-INF/lib/micrometer-commons-1.13.4.jar:/workspace/BOOT-INF/lib/logback-core-1.5.8.jar:/workspace/BOOT-INF/lib/slf4j-api-2.0.16.jar:/workspace/BOOT-INF/lib/log4j-api-2.23.1.jar com.example.demo.NativeApplicationKt [creator] Warning: The option '-H:ReflectionConfigurationResources=META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-websocket/tomcat-reflection.json' is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the future. [creator] Warning: The option '-H:ReflectionConfigurationResources=META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-el/tomcat-reflection.json' is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the future. [creator] Warning: The option '-H:+StaticExecutableWithDynamicLibC' is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the future. [creator] Warning: The option '-H:Name=/layers/paketo-buildpacks_native-image/native-image/com.example.demo.NativeApplicationKt' is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the future. [creator] Warning: The option '-H:ResourceConfigurationResources=META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-core/tomcat-resource.json' is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the future. [creator] Warning: The option '-H:ReflectionConfigurationResources=META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-core/tomcat-reflection.json' is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the future. [creator] Warning: The option '-H:ResourceConfigurationResources=META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-el/tomcat-resource.json' is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the future. [creator] Warning: The option '-H:ResourceConfigurationResources=META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-websocket/tomcat-resource.json' is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the future. [creator] Warning: Please re-evaluate whether any experimental option is required, and either remove or unlock it. The build output lists all active experimental options, including where they come from and possible alternatives. If you think an experimental option should be considered as stable, please file an issue. [creator] ================================================================================ [creator] GraalVM Native Image: Generating 'com.example.demo.NativeApplicationKt' (executable)... [creator] ================================================================================ [creator] For detailed information and explanations on the build output, visit: [creator] https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md [creator] -------------------------------------------------------------------------------- [creator] Warning: The host machine does not support all features of 'x86-64-v3'. Falling back to '-march=compatibility' for best compatibility. [creator] [creator] [1/8] Initializing... (0.0s @ 0.14GB) [creator] Error: Error compiling query code (in /tmp/SVM-7410329447287286679/PosixDirectives.c). Compiler command '/usr/bin/gcc -Wall -Werror -o /tmp/SVM-7410329447287286679/PosixDirectives /tmp/SVM-7410329447287286679/PosixDirectives.c' output included error: [gcc: internal compiler error: Segmentation fault signal terminated program collect2, Please submit a full bug report,, with preprocessed source if appropriate., See file:///usr/share/doc/gcc-11/README.Bugs for instructions.] [creator] -------------------------------------------------------------------------------- [creator] 1.3s (4.9% of total time) in 17 GCs | Peak RSS: 0.81GB | CPU load: 2.84 [creator] ================================================================================ [creator] Finished generating 'com.example.demo.NativeApplicationKt' in 21.4s. [creator] unable to invoke layer creator [creator] unable to contribute native-image layer [creator] error running build [creator] exit status 1 [creator] ERROR: failed to build: exit status 1

Task :bootBuildImage FAILED

FAILURE: Build failed with an exception.

BUILD FAILED in 4m 34s 10 actionable tasks: 4 executed, 6 up-to-date

Steps to Reproduce

  1. Go to https://start.spring.io/#!type=gradle-project-kotlin&language=kotlin&platformVersion=3.3.4&packaging=jar&jvmVersion=23&groupId=com.example&artifactId=native&name=native&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.native&dependencies=native,web
  2. Add a simple hello world restcontroller
  3. Run ./gradlew bootBuildImage -> fail

Additional Context

I've attempted it again for a second time, and the second time I ran ./gradlew bootBuildImage, I had no issue, and the application compiled successfully.

Build Log Output and Error Messages

No response

bodiam commented 1 month ago

When I say I had no issue, I spoke too soon: when I run my image using the following command: docker run --rm -p 8080:8080 docker.io/library/native:0.0.1-SNAPSHOT

I'm getting this error:

qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory

This seems to be related to the buildpack?

selhagani commented 1 month ago

Hi @bodiam,

Thank you for reaching out to us!

To help isolate the issue and confirm whether it is related to GraalVM or not, I followed the steps you provided and ensured that GraalVM was installed and properly configured on my machine. You can download the latest version from here.

Afterward, I ran the command ./gradlew nativeCompile to build the native image and then I ran it and it completed successfully without any issues. Based on this, the problem you're encountering may be related to Docker rather than GraalVM. I suggest reaching out to the Docker support team to further investigate this.

bodiam commented 1 month ago

Hi @selhagani , I think this is related to the Docker build images, they seem to not like ARM processors. I can confirm the nativeCompile command works fine. Thanks for your time on this!