Can I build spring-native boot image in low resources machine (like AWS CodeBuild Linux Small 2vCPUs / 3gb ram)? - aws-codebuild

I want to build boot build image for GraalVM spring native project using AWS CodeBuild called from AWS CodePipeline, but the build process stops at missing RAM resources. I tried the default spring builder and the following one: paketobuildpacks/builder:tiny.
The specification of the machine is Linux Small - BUILD_GENERAL1_SMALL - LINUX_CONTAINER 3 GB RAM, 2 vCPUs and 64 GB of disk space. The image of the environment is aws/codebuild/standard:6.0.
At my local MacBook M1 Pro, it takes around 5.5 GB of ram (checked in Docker Desktop stats), so
I tried at the second plan of BUILD_GENERAL1_MEDIUM as well, and the process went couple lines further, but at the end it was killed as well.
The partial stack trace can be found below (must be cut due to SO spam limits):
> Task :infrastructure:bootBuildImage
Building image 'docker.io/library/experiences-service:latest'
[creator] [1/7] Initializing... (12.1s # 0.56GB)
[creator] Version info: 'GraalVM 22.3.0 Java 17 CE'
[creator] Java version info: '17.0.5+8-LTS'
[creator] C compiler: gcc (linux, x86_64, 7.5.0)
[creator] Garbage collector: Serial GC
[creator] 1 user-specific feature(s)
[creator] - org.springframework.aot.nativex.feature.PreComputeFieldFeature
[creator] The bundle named: i18n.Parsing, has not been found. If the bundle is part of a module, verify the bundle name is a fully qualified class name. Otherwise verify the bundle path is accessible in the classpath.
[creator] The bundle named: i18n.Scalars, has not been found. If the bundle is part of a module, verify the bundle name is a fully qualified class name. Otherwise verify the bundle path is accessible in the classpath.
[creator] [2/7] Performing analysis... [**********] (114.5s # 2.31GB)
[creator] 28,561 (93.30%) of 30,612 classes reachable
[creator] 44,044 (68.12%) of 64,654 fields reachable
[creator] 130,512 (64.11%) of 203,567 methods reachable
[creator] 1,232 classes, 473 fields, and 5,577 methods registered for reflection
[creator] 82 classes, 76 fields, and 64 methods registered for JNI access
[creator] 4 native libraries: dl, pthread, rt, z
[creator] OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000006b5380000, 1065353216, 0) failed; error='Not enough space' (errno=12)
[creator] #
[creator] # There is insufficient memory for the Java Runtime Environment to continue.
[creator] # Native memory allocation (mmap) failed to map 1065353216 bytes for committing reserved memory.
[creator] # An error report file with more information is saved as:
[creator] # /layers/paketo-buildpacks_native-image/native-image/hs_err_pid178.log
[creator] Error: Image build request failed with exit status 1
[creator] unable to invoke layer creator
[creator] unable to contribute native-image layer
Sometimes the process is finished by code 137:
[creator] [2/7] Performing analysis... [**********] (122.4s # 3.24GB)
[creator] 28,561 (93.30%) of 30,612 classes reachable
[creator] 44,044 (68.12%) of 64,654 fields reachable
[creator] 130,512 (64.11%) of 203,565 methods reachable
[creator] 1,232 classes, 473 fields, and 5,577 methods registered for reflection
[creator] 82 classes, 76 fields, and 64 methods registered for JNI access
[creator] 4 native libraries: dl, pthread, rt, z
[creator] Error: Image build request failed with exit status 137
I tried to pass some limits of resources using
passing arguments to the gradle using gradle.properties:
org.gradle.jvmargs=-Xmx512m
passing argument JAVA_TOOL_OPTIONS and BPL_JVM_THREAD_COUNT to the BuildBootImage gradle tasks using the following code. In the logs the limit is logged but there is nothing in results.
tasks.withType<org.springframework.boot.gradle.tasks.bundling.BootBuildImage> {
if (org.apache.tools.ant.taskdefs.condition.Os.isArch("aarch64")) {
builder.set("dashaun/java-native-builder-arm64:latest")
} else {
builder.set("paketobuildpacks/builder:tiny")
}
environment.set(
mapOf(
"JAVA_TOOL_OPTIONS" to "-Xmx512m",
"BPL_JVM_THREAD_COUNT" to "50",
"BP_NATIVE_IMAGE" to "true",
"BP_JVM_VERSION" to "17",
"BP_NATIVE_IMAGE_BUILD_ARGUMENTS" to "--initialize-at-run-time=io.netty.handler.ssl.BouncyCastleAlpnSslUtils"
)
)
imageName.set(rootProject.name)
}
I am looking for any option to pass to the Docker environment or paketobuildpacks to limit used resources?

Related

Java 7 supported Application crashes on Mojave

My application supported on
jdk1.7.0_76
JavaFx2.2.76_b13
Netbeans IDE
It's running successfully till Mac-OSX-HighSierra.
When I tried to run this application on Mojave using Netbeans the application crashes and giving following error.
Launching <fx:deploy> task from /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/jre/../lib/ant-javafx.jar
jfx-deployment-script:
jfx-deployment:
jar:
objc[8382]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/jre/bin/java (0x1018244c0) and /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/jre/lib/jli/./libjli.dylib (0x10b4f3480). One of the two will be used. Which one is undefined.
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGILL (0x4) at pc=0x00007fff4200543b, pid=8382, tid=775
#
# JRE version: Java(TM) SE Runtime Environment (7.0_80-b15) (build 1.7.0_80-b15)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.80-b11 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C [CoreFoundation+0x13f43b] _CFRelease+0x434
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/rahulsharma/NetBeansProjects/CreatFXMLTst/hs_err_pid8382.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Java Result: 134
debug:
jfxsa-debug:
BUILD SUCCESSFUL (total time: 17 seconds)
We're seeing the exact same crash in Firefox (illegal instruction at that address), it's probably an issue in CoreFoundation:
Firefox crashes # CoreFoundation+0x13f43b

SIGSEGV - Fatal Error in JavaFX Application - libjvm.so [duplicate]

#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007ff17a60c678, pid=4219, tid=140673779791616
#
# JRE version: Java(TM) SE Runtime Environment (8.0-b124) (build 1.8.0-ea-b124)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.0-b66 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# V [libjvm.so+0x665678] jni_invoke_nonstatic(JNIEnv_*, JavaValue*, _jobject*, JNICallType, _jmethodID*, JNI_ArgumentPusher*, Thread*)+0x38
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /media/data/K's World/javaFX/ChatApp/hs_err_pid4219.log
Compiled method (c1) 16675 988 3 java.util.concurrent.atomic.AtomicBoolean::set (14 bytes)
total in heap [0x00007ff16535ef50,0x00007ff16535f2a0] = 848
relocation [0x00007ff16535f070,0x00007ff16535f0a0] = 48
main code [0x00007ff16535f0a0,0x00007ff16535f1c0] = 288
stub code [0x00007ff16535f1c0,0x00007ff16535f250] = 144
metadata [0x00007ff16535f250,0x00007ff16535f258] = 8
scopes data [0x00007ff16535f258,0x00007ff16535f268] = 16
scopes pcs [0x00007ff16535f268,0x00007ff16535f298] = 48
dependencies [0x00007ff16535f298,0x00007ff16535f2a0] = 8
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
#
I am writing chat App in javaFx..and I am using eclipse IDE..
My Application is running well but I don't know why suddenly application has been stopped.
It sounds like you're running JavaFX with Java 8 on Linux, and you've run into this bug:
https://bugs.openjdk.java.net/browse/JDK-8141687
App crashes while starting Main.class in JavaFx
ava version "1.8.0_60" Java(TM) SE Runtime Environment (build
1.8.0_60-b27) Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
ADDITIONAL OS VERSION INFORMATION : Mint17.2 Cinnamon 64Bit
SUGGESTION: Try a different version of Java/JavaFX.
Run sudo update-alternatives --config java to see what alternatives are already present on your system. I would downgrade to Java 1.7 if possible.
https://askubuntu.com/questions/272187/setting-jdk-7-as-default
If there are no suitable candidates, use apt-get install openjdk-7-jdk:
https://www.digitalocean.com/community/tutorials/how-to-install-java-on-ubuntu-with-apt-get
I had the same issue (except that it was java-8-oracle build 101) and found out why it was happening:
I have a login screen that appears before my main application and that screen gets closed after the login occurs and, apparently, closing it (or even hiding it) and showing a new window makes it crash.

Microsoft R Server rxSpark Execution

rxRemoteHadoopMRCall()
====== xxxx.cloudapp.azure.com (Master HPA Process) has started run at Sat Mar 18 08:15:43 2017 ======
17/03/18 03:16:36 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where application
Warning: libjvm.so not found in /log/cloudera/parcels/MRS-9.0.1/hadoop, searching system-wide
Internal Error: Cannot reset hdfs internal params while connected to an hdfs file system.
Error in try({ :
Internal Error: Cannot reset hdfs internal params while connected to an hdfs file system.
I wonder if this is a problem with locating JRE. You can try setting JAVA_HOME for your user ($HOME/.bashrc) or for all users (etc/environment) on the node you're connecting to. It should point to a place that correctly resolves this path: $JAVA_HOME/jre/lib/amd64/server/libjvm.so

JVM Crash Problematic Frame: Canonicalizer::do_If

Iam facing JVM Crash cosistently while enabling hotdeploy (USING below java options on starting up JAVA_OPTS -Xmx4096m -XX:MetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=crash -XX:ThreadStackSize=512 -XX:+UseConcMarkSweepGC -XX:ParallelGCThreads=5 -XX:NewRatio=2 -XX:+UnlockDiagnosticVMOptions -XX:-UseLoopPredicate -Xdebug -Xrunjdwp:transport=dt_socket,address=$DEBUG_PORT,server=y,suspend=n -XX:NewRatio=2 -Dspringloaded.synchronize=true JAVA_OPTS=`echo $JAVA_OPTS -Dspringloaded.synchronize=true -javaagent:springloaded-1.2.1.jar -noverify
)
Environment : JDK 1.8 U 66, RHEL 6.7
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007faee9a1e27c, pid=27208, tid=140379827795712
#
# JRE version: Java(TM) SE Runtime Environment (8.0_66-b17) (build 1.8.0_66-b17)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.66-b17 mixed mode linux-amd64 )
# Problematic frame:
# V [libjvm.so+0x35027c] Canonicalizer::do_If(If*)+0x1c
#
# Core dump written. Default location: core.27208
#
# An error report file with more information is saved as:
# hs_err_pid27208.log
# [ timer expired, abort... ]
I've noticed both -javaagent and -noverify in Java options list.
It looks like springloaded agent generates invalid bytecode, while the bytecode verification is explicitly turned off. No surprise, this may lead to unpredictable results including JVM crash.
This is not a JVM problem, but most likely a bug in springloaded agent. Try to remove -noverify option.
-XX:-TieredCompilation may also work around this particular problem, but don't expect application to work correctly if the bytecode fails to pass verification. It's better to stay away from the buggy agent libraries.
4.2.1 Crash in HotSpot Compiler Thread or Compiled Code
If the fatal error log indicates that the crash occurred in a compiler
thread, then it is possible (but not always the case) that you have
encountered a compiler bug. Similarly, if the crash is in compiled
code then it is possible that the compiler has generated incorrect
code.
In the case of the HotSpot Client VM (-client option), the compiler
thread appears in the error log as CompilerThread0. With the HotSpot
Server VM there are multiple compiler threads and these appear in the
error log file as CompilerThread0, CompilerThread1, and AdapterThread.
Below is a fragment of an error log for a compiler bug that was
encountered and fixed during the development of J2SE 5.0. The log file
shows that the HotSpot Server VM is used and the crash occurred in
CompilerThread1. In addition, the log file shows that the Current
CompileTask was the compilation of the java.lang.Thread.setPriority
method.
An unexpected error has been detected by HotSpot Virtual Machine:
:
Java VM: Java HotSpot(TM) Server VM (1.5-internal-debug mixed mode) :
--------------- T H R E A D ---------------
Current thread (0x001e9350): JavaThread "CompilerThread1" daemon
[_thread_in_vm, id=20]
Stack: [0xb2500000,0xb2580000), sp=0xb257e500, free space=505k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code,
C=native code) V [libjvm.so+0xc3b13c] :
Current CompileTask: opto: 11 java.lang.Thread.setPriority(I)V
(53 bytes)
--------------- P R O C E S S ---------------
Java Threads: ( => current thread ) 0x00229930 JavaThread "Low
Memory Detector" daemon [_thread_blocked, id=21]
=>0x001e9350 JavaThread "CompilerThread1" daemon [_thread_in_vm, id=20] :
In this case there are two potential workarounds:
The brute force approach: change the configuration so that the application is run with the -client option to specify the HotSpot
Client VM.
Assume that the bug only occurs during the compilation of the setPriority method and exclude this method from compilation.
The first approach (to use the -client option) might be trivial to
configure in some environments. In others, it might be more difficult
if the configuration is complex or if the command line to configure
the VM is not readily accessible. In general, switching from the
HotSpot Server VM to the HotSpot Client VM also reduces the peak
performance of an application. Depending on the environment, this
might be acceptable until the actual issue is diagnosed and fixed.
The second approach (exclude the method from compilation) requires
creating the file .hotspot_compiler in the working directory of the
application. Below is an example of this file:
exclude java/lang/Thread setPriority
In general the format of this file is exclude CLASS METHOD, where
CLASS is the class (fully qualified with the package name) and METHOD
is the name of the method. Constructor methods are specified as
and static initializers are specified as .
Note - The .hotspot_compiler file is an unsupported interface. It is
documented here solely for the purposes of troubleshooting and finding
a temporary workaround.
Once the application is restarted, the compiler will not attempt to
compile any of the methods listed as excluded in the .hotspot_compiler
file. In some cases this can provide temporary relief until the root
cause of the crash is diagnosed and the bug is fixed.
In order to verify that the HotSpot VM correctly located and processed
the .hotspot_compiler file that is shown in the example above, look
for the following log information at runtime. Note that the file name
separator is a dot, not a slash.
Excluding compile: java.lang.Thread::setPriority
Source
Agree with #apangin, In the program you are doing bytecode intrumentation (-agent) but specifies -noverify. When verification is turned off, you may end up such crashes.
You should not use -noverify or -Xverify:none during byte code intrumentation.
For those of you unfamiliar with bytecode verification, it is simply part of the JVM's classloading process that checks the code for certain dangerous and disallowed behavior. You can (but shouldn't) disable this protection on many JVMs by adding -Xverify:none or -noverify to the Java command line. https://blogs.oracle.com/buck/entry/never_disable_bytecode_verification_in

Java 1.5 crash on AIX 5

I have a problem with Java 1.5.0 for AIX. The error happens just when I log on with specific user on AIX (myuser). When I log on with other user java works ok.
The error come up even when I executed just "java -version" or simply "java" (of course, without quoting). I've tried executing it with the full path: /usr/java5/jre/bin/java but still fails.
There was installed the version 1.4 of java on system too. So the $PATH variable for the user contained /usr/java14/jre/bin, but I removed that value, I even uninstalled that version of java (1.4) so that just java 5 exists on the system, but the error continues.
If I execute "java -fullversion" it doesn't crash.
This is part of the error (the full output is very long):
JVMJ9VM011W Unable to load j9dmp23: No such file or directory
JVMJ9VM011W Unable to load j9jit23: No such file or directory
JVMJ9VM011W Unable to load j9gc23: No such file or directory
JVMJ9VM011W Unable to load j9vrb23: No such file or directory
Unhandled exception
Type=Illegal instruction vmState=0x00000000
J9Generic_Signal_Number=00000010 Signal_Number=00000004 Error_Value=00000000
Signal_Code=0000001e
Handler1=F0719CC8 Handler2=F0714F5C
.....
Target=2_30_20091103_45935_bHdSMr (AIX 5.3)
CPU=ppc (4 logical CPUs) (0x7d0000000 RAM)
JavaVMInitArgs.nOptions=14:
-Xjcl:jclscar_23
-Dcom.ibm.oti.vm.bootstrap.library.path=/usr/java5/jre/bin
-Dsun.boot.library.path=/usr/java5/jre/bin
-Djava.library.path=/usr/java5/jre/bin:/usr/java5/jre/bin:/usr/java5/jre/bin/classic:/usr/java5/jre/bin:/sqllib/lib:/home/myuser/comm:/home/myuser/sys:/home/myuser/bin:/db2util/db2adm/sqllib/lib64:/usr/java5/jre/bin/j9vm:/usr/lib
-Djava.home=/usr/java5/jre
-Djava.ext.dirs=/usr/java5/jre/lib/ext
-Duser.dir=/home/myuser
_j2se_j9=70912 (extra info: F070EA2C)
-Xdump
vfprintf (extra info: 300017A4)
-Dinvokedviajava
-Djava.class.path=/db2util/db2adm/sqllib/java/db2java.zip:/db2util/db2adm/sqllib/java/db2jcc.jar:/db2util/db2adm/sqllib/java/sqlj.zip:/db2util/db2adm/sqllib/function:/db2util/db2adm/sqllib/java/db2jcc_license_cu.jar:.
vfprintf
_port_library (extra info: F070EE30)
Note: "Enable full CORE dump" in smit is set to FALSE and as a result there will be limited threading information in core file.
Note: dump may be truncated if "ulimit -c" is set too low
Generated system dump: {default OS core name}
(no Thread object associated with thread)
(no Thread object associated with thread)
Unhandled exception in signal handler
ksh: 2179192 IOT/Abort trap(coredump)
I found the error. The problem is a line on the .profile which sets the environment variable LIBPATH:
export LIBPATH=/home/myuser/sys
I deleted that line in the .profile and java worked.