8339535: JVM crashes with -Xshare:dump -XX:+SegmentedCodeCache

Reviewed-by: ccheung, dholmes, kvn
This commit is contained in:
Ioi Lam 2024-12-04 18:45:35 +00:00
parent e1695f6c40
commit 6aa7667e9d
3 changed files with 30 additions and 28 deletions

View File

@ -1775,14 +1775,20 @@ bool Arguments::sun_java_launcher_is_altjvm() {
//===========================================================================================================
// Parsing of main arguments
unsigned int addreads_count = 0;
unsigned int addexports_count = 0;
unsigned int addopens_count = 0;
unsigned int patch_mod_count = 0;
unsigned int enable_native_access_count = 0;
static unsigned int addreads_count = 0;
static unsigned int addexports_count = 0;
static unsigned int addopens_count = 0;
static unsigned int patch_mod_count = 0;
static unsigned int enable_native_access_count = 0;
static bool patch_mod_javabase = false;
// Check the consistency of vm_init_args
bool Arguments::check_vm_args_consistency() {
// This may modify compiler flags. Must be called before CompilerConfig::check_args_consistency()
if (!CDSConfig::check_vm_args_consistency(patch_mod_javabase, mode_flag_cmd_line)) {
return false;
}
// Method for adding checks for flag consistency.
// The intent is to warn the user of all possible conflicts,
// before returning an error.
@ -1953,8 +1959,6 @@ jint Arguments::parse_vm_init_args(const JavaVMInitArgs *vm_options_args,
const JavaVMInitArgs *java_tool_options_args,
const JavaVMInitArgs *java_options_args,
const JavaVMInitArgs *cmd_line_args) {
bool patch_mod_javabase = false;
// Save default settings for some mode flags
Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods;
Arguments::_UseOnStackReplacement = UseOnStackReplacement;
@ -1968,27 +1972,27 @@ jint Arguments::parse_vm_init_args(const JavaVMInitArgs *vm_options_args,
set_mode_flags(_mixed);
// Parse args structure generated from java.base vm options resource
jint result = parse_each_vm_init_arg(vm_options_args, &patch_mod_javabase, JVMFlagOrigin::JIMAGE_RESOURCE);
jint result = parse_each_vm_init_arg(vm_options_args, JVMFlagOrigin::JIMAGE_RESOURCE);
if (result != JNI_OK) {
return result;
}
// Parse args structure generated from JAVA_TOOL_OPTIONS environment
// variable (if present).
result = parse_each_vm_init_arg(java_tool_options_args, &patch_mod_javabase, JVMFlagOrigin::ENVIRON_VAR);
result = parse_each_vm_init_arg(java_tool_options_args, JVMFlagOrigin::ENVIRON_VAR);
if (result != JNI_OK) {
return result;
}
// Parse args structure generated from the command line flags.
result = parse_each_vm_init_arg(cmd_line_args, &patch_mod_javabase, JVMFlagOrigin::COMMAND_LINE);
result = parse_each_vm_init_arg(cmd_line_args, JVMFlagOrigin::COMMAND_LINE);
if (result != JNI_OK) {
return result;
}
// Parse args structure generated from the _JAVA_OPTIONS environment
// variable (if present) (mimics classic VM)
result = parse_each_vm_init_arg(java_options_args, &patch_mod_javabase, JVMFlagOrigin::ENVIRON_VAR);
result = parse_each_vm_init_arg(java_options_args, JVMFlagOrigin::ENVIRON_VAR);
if (result != JNI_OK) {
return result;
}
@ -2009,7 +2013,7 @@ jint Arguments::parse_vm_init_args(const JavaVMInitArgs *vm_options_args,
SystemMemoryBarrier::initialize();
// Do final processing now that all arguments have been parsed
result = finalize_vm_init_args(patch_mod_javabase);
result = finalize_vm_init_args();
if (result != JNI_OK) {
return result;
}
@ -2064,7 +2068,7 @@ static bool valid_jdwp_agent(char *name, bool is_path) {
}
#endif
int Arguments::process_patch_mod_option(const char* patch_mod_tail, bool* patch_mod_javabase) {
int Arguments::process_patch_mod_option(const char* patch_mod_tail) {
// --patch-module=<module>=<file>(<pathsep><file>)*
assert(patch_mod_tail != nullptr, "Unexpected null patch-module value");
// Find the equal sign between the module name and the path specification
@ -2080,7 +2084,7 @@ int Arguments::process_patch_mod_option(const char* patch_mod_tail, bool* patch_
memcpy(module_name, patch_mod_tail, module_len);
*(module_name + module_len) = '\0';
// The path piece begins one past the module_equal sign
add_patch_mod_prefix(module_name, module_equal + 1, patch_mod_javabase);
add_patch_mod_prefix(module_name, module_equal + 1);
FREE_C_HEAP_ARRAY(char, module_name);
if (!create_numbered_module_property("jdk.module.patch", patch_mod_tail, patch_mod_count++)) {
return JNI_ENOMEM;
@ -2146,7 +2150,7 @@ jint Arguments::parse_xss(const JavaVMOption* option, const char* tail, intx* ou
return JNI_OK;
}
jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_mod_javabase, JVMFlagOrigin origin) {
jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, JVMFlagOrigin origin) {
// For match_option to return remaining or value part of option string
const char* tail;
@ -2273,7 +2277,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
}
} else if (match_option(option, "--patch-module=", &tail)) {
// --patch-module=<module>=<file>(<pathsep><file>)*
int res = process_patch_mod_option(tail, patch_mod_javabase);
int res = process_patch_mod_option(tail);
if (res != JNI_OK) {
return res;
}
@ -2822,16 +2826,16 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
return JNI_OK;
}
void Arguments::add_patch_mod_prefix(const char* module_name, const char* path, bool* patch_mod_javabase) {
void Arguments::add_patch_mod_prefix(const char* module_name, const char* path) {
// For java.base check for duplicate --patch-module options being specified on the command line.
// This check is only required for java.base, all other duplicate module specifications
// will be checked during module system initialization. The module system initialization
// will throw an ExceptionInInitializerError if this situation occurs.
if (strcmp(module_name, JAVA_BASE_NAME) == 0) {
if (*patch_mod_javabase) {
if (patch_mod_javabase) {
vm_exit_during_initialization("Cannot specify " JAVA_BASE_NAME " more than once to --patch-module");
} else {
*patch_mod_javabase = true;
patch_mod_javabase = true;
}
}
@ -2883,7 +2887,7 @@ void Arguments::fix_appclasspath() {
}
}
jint Arguments::finalize_vm_init_args(bool patch_mod_javabase) {
jint Arguments::finalize_vm_init_args() {
// check if the default lib/endorsed directory exists; if so, error
char path[JVM_MAXPATHLEN];
const char* fileSep = os::file_separator();
@ -2957,9 +2961,6 @@ jint Arguments::finalize_vm_init_args(bool patch_mod_javabase) {
return JNI_ERR;
}
if (!CDSConfig::check_vm_args_consistency(patch_mod_javabase, mode_flag_cmd_line)) {
return JNI_ERR;
}
#ifndef CAN_SHOW_REGISTERS_ON_ASSERT
UNSUPPORTED_OPTION(ShowRegistersOnAssert);

View File

@ -290,7 +290,7 @@ class Arguments : AllStatic {
static bool create_module_property(const char* prop_name, const char* prop_value, PropertyInternal internal);
static bool create_numbered_module_property(const char* prop_base_name, const char* prop_value, unsigned int count);
static int process_patch_mod_option(const char* patch_mod_tail, bool* patch_mod_javabase);
static int process_patch_mod_option(const char* patch_mod_tail);
// Aggressive optimization flags.
static jint set_aggressive_opts_flags();
@ -325,8 +325,8 @@ class Arguments : AllStatic {
const JavaVMInitArgs *java_tool_options_args,
const JavaVMInitArgs *java_options_args,
const JavaVMInitArgs *cmd_line_args);
static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_mod_javabase, JVMFlagOrigin origin);
static jint finalize_vm_init_args(bool patch_mod_javabase);
static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, JVMFlagOrigin origin);
static jint finalize_vm_init_args();
static bool is_bad_option(const JavaVMOption* option, jboolean ignore, const char* option_type);
static bool is_bad_option(const JavaVMOption* option, jboolean ignore) {
@ -474,7 +474,7 @@ class Arguments : AllStatic {
static void set_ext_dirs(char *value) { _ext_dirs = os::strdup_check_oom(value); }
// Set up the underlying pieces of the boot class path
static void add_patch_mod_prefix(const char *module_name, const char *path, bool* patch_mod_javabase);
static void add_patch_mod_prefix(const char *module_name, const char *path);
static void set_boot_class_path(const char *value, bool has_jimage) {
// During start up, set by os::set_boot_path()
assert(get_boot_class_path() == nullptr, "Boot class path previously set");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -63,6 +63,7 @@ public class CommandLineFlagCombo {
"-Xint",
"-Xmixed",
"-Xcomp",
"-XX:+SegmentedCodeCache",
};
public static void main(String[] args) throws Exception {