-
Bug
-
Resolution: Unresolved
-
P2
-
8
-
x86_64
ADDITIONAL SYSTEM INFORMATION :
Also occurs with JDK 17 (latest version). The latest release that is working for us is JDK11, however other users have reported a similar issue with an identical stack trace as far back as JDK 8, so I'm not sure this is a regression in JDK 17.
We have also seen this crash in other environments, including Windows (native and WSL) and Oracle Linux, and with different distributions of OpenJDK (Temurin, Coretto, Microsoft, Azul and others).
A DESCRIPTION OF THE PROBLEM :
The Java Runtime Environment crashes with a SIGSEGV during execution of a Groovy script.
While the original script cannot be published, we managed to reduce it to a significantly smaller size with just a few open source dependencies. In essence, the script generates code from an Apache Velocity template. The reduced script does crash the JVM reliably, however this does not happen on every execution.
It is quite easy to work around the issue by modifying the compiled code, however we were unsuccessful doing so via JVM options (e.g. compile commands excluding certain classes from compilation).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See code in https://github.com/mroth23/jvm-crash
Source the environment variables (they are queried in the code and appear to be important for the crash) and execute the program.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The script should execute correctly with no output.
ACTUAL -
$ java -classpath "./_deps/*" org.codehaus.groovy.tools.GroovyStarter --main groovy.ui.GroovyMain --classpath ./src/main/java:./src/main/resources ./src/main/java/de/crash/the/jvm/srv/gen/CrashTheJvm.groovy -e
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x000076b017a944e0, pid=22442, tid=22465
#
# JRE version: Java(TM) SE Runtime Environment (21.0.7+8) (build 21.0.7+8-LTS-245)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (21.0.7+8-LTS-245, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0xc944e0] Node::uncast(bool) const+0x0
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E" (or dumping to /home/mroth/src/jvm-crash/core.22442)
#
# An error report file with more information is saved as:
# /home/mroth/src/jvm-crash/hs_err_pid22442.log
[thread 22463 also had an error]
#
# Compiler replay data is saved as:
# /home/mroth/src/jvm-crash/replay_pid22442.log
#
# If you would like to submit a bug report, please visit:
# https://bugreport.java.com/bugreport/crash.jsp
#
[1] 22442 IOT instruction (core dumped) java -classpath "./_deps/*" org.codehaus.groovy.tools.GroovyStarter --main
---------- BEGIN SOURCE ----------
See https://github.com/mroth23/jvm-crash
package de.crash.the.jvm.srv.gen
import groovy.transform.EqualsAndHashCode
import groovy.util.logging.Log4j2
import org.apache.commons.configuration2.PropertiesConfiguration
import org.apache.commons.configuration2.convert.DisabledListDelimiterHandler
import org.apache.commons.lang3.StringUtils
import org.apache.velocity.VelocityContext
import org.apache.velocity.app.VelocityEngine
import java.util.*
@Log4j2
@groovy.transform.InheritConstructors
class CrashTheJvm {
public static void main(String[] args)
{
new CrashTheJvm().execute()
}
protected void execute() {
Properties properties = new Properties()
properties.put('resource.loader.file.cache', true)
properties.put('resource.loader.classpath.class', 'org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader')
properties.put('resource.loaders', 'classpath')
properties.put('webapp-slf4j-logger.level', 'debug')
VelocityEngine engine = new VelocityEngine(properties)
Map<String, String> description = new HashMap<>()
description.put("test", "test")
var columnDefinition = ColumnDefinition.mock(description)
var cols = new ArrayList<ColumnDefinition>()
for (int i = 0; i < 200; i++) {
cols.add(columnDefinition)
}
for (int i = 0; i < 2000; i++) {
VelocityContext context = new VelocityContext()
context.put('cols', cols)
def writer = new StringWriter()
def template = engine.getTemplate('etyif.java')
template.merge(context, writer)
}
}
static class ColumnDefinition {
Map<String, String> description
String m_comment
static mock(Map<String, String> description) {
ColumnDefinition cd = new ColumnDefinition()
cd.description = description
cd.m_comment = 'Test1234'
cd
}
String description(String a_language) {
description[a_language] ?: m_comment
}
String description() {
description(_Lib.getProp("lang", Locale.GERMAN.getLanguage()))
}
}
static class _Lib {
static String getProp(String a_name, String a_default = null,
boolean a_ignoreCase = false) {
_Configuration.get().getValue(a_name, a_default)
}
static String env(String a_name) {
return System.getenv(a_name)
}
static String getFoo() {
return env("UMGEBUNG")
}
static String getBar() {
return env("STANDORT")
}
static String getBaz() {
return StringUtils.defaultString(env("SYSTEMIDENTIFIER"))
}
}
static class _Configuration {
static Map<_ConfScope, _Configuration> m_configurations = new HashMap<>();
private _ConfScope m_scope
private PropertiesConfiguration m_configuration
private _Configuration(_ConfScope a_scope, PropertiesConfiguration a_configuration) {
m_scope = a_scope
m_configuration = a_configuration
}
public String getValue(String a_key, String a_default = null) {
def value = m_configuration.getString(a_key, a_default)
value = System.getProperty(a_key, value)
value
}
static get(_ConfScope a_scope = null) {
_ConfScope scope = _ConfScope.fromEnvironment()
if (!m_configurations.containsKey(scope)) {
m_configurations.put(scope, new _Configuration(scope, read(scope)))
}
m_configurations.get(scope)
}
static final PropertiesConfiguration emptyConfiguration(_ConfScope a_scope) {
PropertiesConfiguration configuration = new PropertiesConfiguration()
configuration.setListDelimiterHandler(new DisabledListDelimiterHandler())
configuration
}
static PropertiesConfiguration read(_ConfScope a_scope) {
PropertiesConfiguration configuration = emptyConfiguration(a_scope)
for (int i = 0; i < 555; i++) {
configuration.addProperty("prop_" + i, i)
}
configuration
}
}
@EqualsAndHashCode(includeFields = true)
static class _ConfScope {
private static final int SIZE = 3
private final String[] m_components = new String[SIZE]
public static final String WILDCARD = '*'
private static final int INDEX_FOO = 0
private static final int INDEX_BAR = 1
private static final int INDEX_BAZ = 2
_ConfScope(String a_foo = WILDCARD, String a_bar = WILDCARD, String a_baz = WILDCARD) {
m_components[INDEX_FOO] = StringUtils.isEmpty(a_foo) ? _Lib.getFoo() : a_foo
m_components[INDEX_BAR] = StringUtils.isEmpty(a_bar) ? _Lib.getBar() : a_bar
m_components[INDEX_BAZ] = StringUtils.isEmpty(a_baz) ? _Lib.getBaz() : a_baz
}
static fromEnvironment() {
new _ConfScope(_Lib.getFoo(), _Lib.getBar(), _Lib.getBaz())
}
}
}
---------- END SOURCE ----------
Also occurs with JDK 17 (latest version). The latest release that is working for us is JDK11, however other users have reported a similar issue with an identical stack trace as far back as JDK 8, so I'm not sure this is a regression in JDK 17.
We have also seen this crash in other environments, including Windows (native and WSL) and Oracle Linux, and with different distributions of OpenJDK (Temurin, Coretto, Microsoft, Azul and others).
A DESCRIPTION OF THE PROBLEM :
The Java Runtime Environment crashes with a SIGSEGV during execution of a Groovy script.
While the original script cannot be published, we managed to reduce it to a significantly smaller size with just a few open source dependencies. In essence, the script generates code from an Apache Velocity template. The reduced script does crash the JVM reliably, however this does not happen on every execution.
It is quite easy to work around the issue by modifying the compiled code, however we were unsuccessful doing so via JVM options (e.g. compile commands excluding certain classes from compilation).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See code in https://github.com/mroth23/jvm-crash
Source the environment variables (they are queried in the code and appear to be important for the crash) and execute the program.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The script should execute correctly with no output.
ACTUAL -
$ java -classpath "./_deps/*" org.codehaus.groovy.tools.GroovyStarter --main groovy.ui.GroovyMain --classpath ./src/main/java:./src/main/resources ./src/main/java/de/crash/the/jvm/srv/gen/CrashTheJvm.groovy -e
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x000076b017a944e0, pid=22442, tid=22465
#
# JRE version: Java(TM) SE Runtime Environment (21.0.7+8) (build 21.0.7+8-LTS-245)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (21.0.7+8-LTS-245, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0xc944e0] Node::uncast(bool) const+0x0
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E" (or dumping to /home/mroth/src/jvm-crash/core.22442)
#
# An error report file with more information is saved as:
# /home/mroth/src/jvm-crash/hs_err_pid22442.log
[thread 22463 also had an error]
#
# Compiler replay data is saved as:
# /home/mroth/src/jvm-crash/replay_pid22442.log
#
# If you would like to submit a bug report, please visit:
# https://bugreport.java.com/bugreport/crash.jsp
#
[1] 22442 IOT instruction (core dumped) java -classpath "./_deps/*" org.codehaus.groovy.tools.GroovyStarter --main
---------- BEGIN SOURCE ----------
See https://github.com/mroth23/jvm-crash
package de.crash.the.jvm.srv.gen
import groovy.transform.EqualsAndHashCode
import groovy.util.logging.Log4j2
import org.apache.commons.configuration2.PropertiesConfiguration
import org.apache.commons.configuration2.convert.DisabledListDelimiterHandler
import org.apache.commons.lang3.StringUtils
import org.apache.velocity.VelocityContext
import org.apache.velocity.app.VelocityEngine
import java.util.*
@Log4j2
@groovy.transform.InheritConstructors
class CrashTheJvm {
public static void main(String[] args)
{
new CrashTheJvm().execute()
}
protected void execute() {
Properties properties = new Properties()
properties.put('resource.loader.file.cache', true)
properties.put('resource.loader.classpath.class', 'org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader')
properties.put('resource.loaders', 'classpath')
properties.put('webapp-slf4j-logger.level', 'debug')
VelocityEngine engine = new VelocityEngine(properties)
Map<String, String> description = new HashMap<>()
description.put("test", "test")
var columnDefinition = ColumnDefinition.mock(description)
var cols = new ArrayList<ColumnDefinition>()
for (int i = 0; i < 200; i++) {
cols.add(columnDefinition)
}
for (int i = 0; i < 2000; i++) {
VelocityContext context = new VelocityContext()
context.put('cols', cols)
def writer = new StringWriter()
def template = engine.getTemplate('etyif.java')
template.merge(context, writer)
}
}
static class ColumnDefinition {
Map<String, String> description
String m_comment
static mock(Map<String, String> description) {
ColumnDefinition cd = new ColumnDefinition()
cd.description = description
cd.m_comment = 'Test1234'
cd
}
String description(String a_language) {
description[a_language] ?: m_comment
}
String description() {
description(_Lib.getProp("lang", Locale.GERMAN.getLanguage()))
}
}
static class _Lib {
static String getProp(String a_name, String a_default = null,
boolean a_ignoreCase = false) {
_Configuration.get().getValue(a_name, a_default)
}
static String env(String a_name) {
return System.getenv(a_name)
}
static String getFoo() {
return env("UMGEBUNG")
}
static String getBar() {
return env("STANDORT")
}
static String getBaz() {
return StringUtils.defaultString(env("SYSTEMIDENTIFIER"))
}
}
static class _Configuration {
static Map<_ConfScope, _Configuration> m_configurations = new HashMap<>();
private _ConfScope m_scope
private PropertiesConfiguration m_configuration
private _Configuration(_ConfScope a_scope, PropertiesConfiguration a_configuration) {
m_scope = a_scope
m_configuration = a_configuration
}
public String getValue(String a_key, String a_default = null) {
def value = m_configuration.getString(a_key, a_default)
value = System.getProperty(a_key, value)
value
}
static get(_ConfScope a_scope = null) {
_ConfScope scope = _ConfScope.fromEnvironment()
if (!m_configurations.containsKey(scope)) {
m_configurations.put(scope, new _Configuration(scope, read(scope)))
}
m_configurations.get(scope)
}
static final PropertiesConfiguration emptyConfiguration(_ConfScope a_scope) {
PropertiesConfiguration configuration = new PropertiesConfiguration()
configuration.setListDelimiterHandler(new DisabledListDelimiterHandler())
configuration
}
static PropertiesConfiguration read(_ConfScope a_scope) {
PropertiesConfiguration configuration = emptyConfiguration(a_scope)
for (int i = 0; i < 555; i++) {
configuration.addProperty("prop_" + i, i)
}
configuration
}
}
@EqualsAndHashCode(includeFields = true)
static class _ConfScope {
private static final int SIZE = 3
private final String[] m_components = new String[SIZE]
public static final String WILDCARD = '*'
private static final int INDEX_FOO = 0
private static final int INDEX_BAR = 1
private static final int INDEX_BAZ = 2
_ConfScope(String a_foo = WILDCARD, String a_bar = WILDCARD, String a_baz = WILDCARD) {
m_components[INDEX_FOO] = StringUtils.isEmpty(a_foo) ? _Lib.getFoo() : a_foo
m_components[INDEX_BAR] = StringUtils.isEmpty(a_bar) ? _Lib.getBar() : a_bar
m_components[INDEX_BAZ] = StringUtils.isEmpty(a_baz) ? _Lib.getBaz() : a_baz
}
static fromEnvironment() {
new _ConfScope(_Lib.getFoo(), _Lib.getBar(), _Lib.getBaz())
}
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-8181499 [Graal] null-value in LambdaForm crashes compiler
-
- Closed
-