Skip to content

Commit 6b02446

Browse files
TimPushkinJan Kratochvil
authored and
Radim Vansa
committed
8349131: [CRaC] Internal error on old glibc with pre-set GLIBC_TUNABLES and CPUFeatures restriction
Co-authored-by: Jan Kratochvil <jkratochvil@openjdk.org> Co-authored-by: Timofei Pushkin <tpushkin@openjdk.org> Reviewed-by: rvansa
1 parent 3979422 commit 6b02446

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/hotspot/cpu/x86/vm_version_x86.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -930,9 +930,10 @@ const size_t VM_Version::glibc_prefix_len = strlen(glibc_prefix);
930930

931931
bool VM_Version::glibc_env_set(char *disable_str) {
932932
#define TUNABLES_NAME "GLIBC_TUNABLES"
933+
#define REEXEC_NAME "HOTSPOT_GLIBC_TUNABLES_REEXEC"
933934
char *env_val = disable_str;
934935
const char *env = getenv(TUNABLES_NAME);
935-
if (env && strcmp(env, env_val) == 0) {
936+
if (env && (strcmp(env, env_val) == 0 || (!INCLUDE_CPU_FEATURE_ACTIVE && getenv(REEXEC_NAME)))) {
936937
if (!INCLUDE_CPU_FEATURE_ACTIVE) {
937938
if (ShowCPUFeatures) {
938939
tty->print_cr("Environment variable already set, glibc CPU_FEATURE_ACTIVE is unavailable - re-exec suppressed: " TUNABLES_NAME "=%s", env);
@@ -968,7 +969,6 @@ bool VM_Version::glibc_env_set(char *disable_str) {
968969
if (err)
969970
vm_exit_during_initialization(err_msg("setenv " TUNABLES_NAME " error: %m"));
970971

971-
#define REEXEC_NAME "HOTSPOT_GLIBC_TUNABLES_REEXEC"
972972
if (getenv(REEXEC_NAME))
973973
vm_exit_during_initialization(err_msg("internal error: " TUNABLES_NAME "=%s failed and " REEXEC_NAME " is set", disable_str));
974974
if (setenv(REEXEC_NAME, "1", 1))
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#! /bin/bash
2+
# @test
3+
# @requires os.family == "linux"
4+
# @requires os.arch=="amd64" | os.arch=="x86_64"
5+
# @run shell SimpleCPUFeatures.sh
6+
# @summary On old glibc (without INCLUDE_CPU_FEATURE_ACTIVE) one could get an internal error.
7+
# Error occurred during initialization of VM
8+
# internal error: GLIBC_TUNABLES=:glibc.cpu.hwcaps=,-AVX,-FMA,-AVX2,-BMI1,-BMI2,-ERMS,-LZCNT,-SSSE3,-POPCNT,-SSE4_1,-SSE4_2,-AVX512F,-AVX512CD,-AVX512BW,-AVX512DQ,-AVX512VL,-IBT,-MOVBE,-SHSTK,-XSAVE,-OSXSAVE,-HTT failed and HOTSPOT_GLIBC_TUNABLES_REEXEC is set
9+
10+
set -ex
11+
12+
export JAVA_HOME=$TESTJAVA
13+
export GLIBC_TUNABLES=glibc.pthread.rseq=0
14+
$JAVA_HOME/bin/java -XX:CPUFeatures=generic -XX:+ShowCPUFeatures -version 2>&1 | tee /proc/self/fd/2 | grep -q 'openjdk version'
15+
16+
exit 0

0 commit comments

Comments
 (0)