Skip to content

Commit 6aa7667

Browse files
committed
8339535: JVM crashes with -Xshare:dump -XX:+SegmentedCodeCache
Reviewed-by: ccheung, dholmes, kvn
1 parent e1695f6 commit 6aa7667

File tree

3 files changed

+30
-28
lines changed

3 files changed

+30
-28
lines changed

src/hotspot/share/runtime/arguments.cpp

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,14 +1775,20 @@ bool Arguments::sun_java_launcher_is_altjvm() {
17751775
//===========================================================================================================
17761776
// Parsing of main arguments
17771777

1778-
unsigned int addreads_count = 0;
1779-
unsigned int addexports_count = 0;
1780-
unsigned int addopens_count = 0;
1781-
unsigned int patch_mod_count = 0;
1782-
unsigned int enable_native_access_count = 0;
1778+
static unsigned int addreads_count = 0;
1779+
static unsigned int addexports_count = 0;
1780+
static unsigned int addopens_count = 0;
1781+
static unsigned int patch_mod_count = 0;
1782+
static unsigned int enable_native_access_count = 0;
1783+
static bool patch_mod_javabase = false;
17831784

17841785
// Check the consistency of vm_init_args
17851786
bool Arguments::check_vm_args_consistency() {
1787+
// This may modify compiler flags. Must be called before CompilerConfig::check_args_consistency()
1788+
if (!CDSConfig::check_vm_args_consistency(patch_mod_javabase, mode_flag_cmd_line)) {
1789+
return false;
1790+
}
1791+
17861792
// Method for adding checks for flag consistency.
17871793
// The intent is to warn the user of all possible conflicts,
17881794
// before returning an error.
@@ -1953,8 +1959,6 @@ jint Arguments::parse_vm_init_args(const JavaVMInitArgs *vm_options_args,
19531959
const JavaVMInitArgs *java_tool_options_args,
19541960
const JavaVMInitArgs *java_options_args,
19551961
const JavaVMInitArgs *cmd_line_args) {
1956-
bool patch_mod_javabase = false;
1957-
19581962
// Save default settings for some mode flags
19591963
Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods;
19601964
Arguments::_UseOnStackReplacement = UseOnStackReplacement;
@@ -1968,27 +1972,27 @@ jint Arguments::parse_vm_init_args(const JavaVMInitArgs *vm_options_args,
19681972
set_mode_flags(_mixed);
19691973

19701974
// Parse args structure generated from java.base vm options resource
1971-
jint result = parse_each_vm_init_arg(vm_options_args, &patch_mod_javabase, JVMFlagOrigin::JIMAGE_RESOURCE);
1975+
jint result = parse_each_vm_init_arg(vm_options_args, JVMFlagOrigin::JIMAGE_RESOURCE);
19721976
if (result != JNI_OK) {
19731977
return result;
19741978
}
19751979

19761980
// Parse args structure generated from JAVA_TOOL_OPTIONS environment
19771981
// variable (if present).
1978-
result = parse_each_vm_init_arg(java_tool_options_args, &patch_mod_javabase, JVMFlagOrigin::ENVIRON_VAR);
1982+
result = parse_each_vm_init_arg(java_tool_options_args, JVMFlagOrigin::ENVIRON_VAR);
19791983
if (result != JNI_OK) {
19801984
return result;
19811985
}
19821986

19831987
// Parse args structure generated from the command line flags.
1984-
result = parse_each_vm_init_arg(cmd_line_args, &patch_mod_javabase, JVMFlagOrigin::COMMAND_LINE);
1988+
result = parse_each_vm_init_arg(cmd_line_args, JVMFlagOrigin::COMMAND_LINE);
19851989
if (result != JNI_OK) {
19861990
return result;
19871991
}
19881992

19891993
// Parse args structure generated from the _JAVA_OPTIONS environment
19901994
// variable (if present) (mimics classic VM)
1991-
result = parse_each_vm_init_arg(java_options_args, &patch_mod_javabase, JVMFlagOrigin::ENVIRON_VAR);
1995+
result = parse_each_vm_init_arg(java_options_args, JVMFlagOrigin::ENVIRON_VAR);
19921996
if (result != JNI_OK) {
19931997
return result;
19941998
}
@@ -2009,7 +2013,7 @@ jint Arguments::parse_vm_init_args(const JavaVMInitArgs *vm_options_args,
20092013
SystemMemoryBarrier::initialize();
20102014

20112015
// Do final processing now that all arguments have been parsed
2012-
result = finalize_vm_init_args(patch_mod_javabase);
2016+
result = finalize_vm_init_args();
20132017
if (result != JNI_OK) {
20142018
return result;
20152019
}
@@ -2064,7 +2068,7 @@ static bool valid_jdwp_agent(char *name, bool is_path) {
20642068
}
20652069
#endif
20662070

2067-
int Arguments::process_patch_mod_option(const char* patch_mod_tail, bool* patch_mod_javabase) {
2071+
int Arguments::process_patch_mod_option(const char* patch_mod_tail) {
20682072
// --patch-module=<module>=<file>(<pathsep><file>)*
20692073
assert(patch_mod_tail != nullptr, "Unexpected null patch-module value");
20702074
// 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_
20802084
memcpy(module_name, patch_mod_tail, module_len);
20812085
*(module_name + module_len) = '\0';
20822086
// The path piece begins one past the module_equal sign
2083-
add_patch_mod_prefix(module_name, module_equal + 1, patch_mod_javabase);
2087+
add_patch_mod_prefix(module_name, module_equal + 1);
20842088
FREE_C_HEAP_ARRAY(char, module_name);
20852089
if (!create_numbered_module_property("jdk.module.patch", patch_mod_tail, patch_mod_count++)) {
20862090
return JNI_ENOMEM;
@@ -2146,7 +2150,7 @@ jint Arguments::parse_xss(const JavaVMOption* option, const char* tail, intx* ou
21462150
return JNI_OK;
21472151
}
21482152

2149-
jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_mod_javabase, JVMFlagOrigin origin) {
2153+
jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, JVMFlagOrigin origin) {
21502154
// For match_option to return remaining or value part of option string
21512155
const char* tail;
21522156

@@ -2273,7 +2277,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
22732277
}
22742278
} else if (match_option(option, "--patch-module=", &tail)) {
22752279
// --patch-module=<module>=<file>(<pathsep><file>)*
2276-
int res = process_patch_mod_option(tail, patch_mod_javabase);
2280+
int res = process_patch_mod_option(tail);
22772281
if (res != JNI_OK) {
22782282
return res;
22792283
}
@@ -2822,16 +2826,16 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
28222826
return JNI_OK;
28232827
}
28242828

2825-
void Arguments::add_patch_mod_prefix(const char* module_name, const char* path, bool* patch_mod_javabase) {
2829+
void Arguments::add_patch_mod_prefix(const char* module_name, const char* path) {
28262830
// For java.base check for duplicate --patch-module options being specified on the command line.
28272831
// This check is only required for java.base, all other duplicate module specifications
28282832
// will be checked during module system initialization. The module system initialization
28292833
// will throw an ExceptionInInitializerError if this situation occurs.
28302834
if (strcmp(module_name, JAVA_BASE_NAME) == 0) {
2831-
if (*patch_mod_javabase) {
2835+
if (patch_mod_javabase) {
28322836
vm_exit_during_initialization("Cannot specify " JAVA_BASE_NAME " more than once to --patch-module");
28332837
} else {
2834-
*patch_mod_javabase = true;
2838+
patch_mod_javabase = true;
28352839
}
28362840
}
28372841

@@ -2883,7 +2887,7 @@ void Arguments::fix_appclasspath() {
28832887
}
28842888
}
28852889

2886-
jint Arguments::finalize_vm_init_args(bool patch_mod_javabase) {
2890+
jint Arguments::finalize_vm_init_args() {
28872891
// check if the default lib/endorsed directory exists; if so, error
28882892
char path[JVM_MAXPATHLEN];
28892893
const char* fileSep = os::file_separator();
@@ -2957,9 +2961,6 @@ jint Arguments::finalize_vm_init_args(bool patch_mod_javabase) {
29572961
return JNI_ERR;
29582962
}
29592963

2960-
if (!CDSConfig::check_vm_args_consistency(patch_mod_javabase, mode_flag_cmd_line)) {
2961-
return JNI_ERR;
2962-
}
29632964

29642965
#ifndef CAN_SHOW_REGISTERS_ON_ASSERT
29652966
UNSUPPORTED_OPTION(ShowRegistersOnAssert);

src/hotspot/share/runtime/arguments.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ class Arguments : AllStatic {
290290
static bool create_module_property(const char* prop_name, const char* prop_value, PropertyInternal internal);
291291
static bool create_numbered_module_property(const char* prop_base_name, const char* prop_value, unsigned int count);
292292

293-
static int process_patch_mod_option(const char* patch_mod_tail, bool* patch_mod_javabase);
293+
static int process_patch_mod_option(const char* patch_mod_tail);
294294

295295
// Aggressive optimization flags.
296296
static jint set_aggressive_opts_flags();
@@ -325,8 +325,8 @@ class Arguments : AllStatic {
325325
const JavaVMInitArgs *java_tool_options_args,
326326
const JavaVMInitArgs *java_options_args,
327327
const JavaVMInitArgs *cmd_line_args);
328-
static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_mod_javabase, JVMFlagOrigin origin);
329-
static jint finalize_vm_init_args(bool patch_mod_javabase);
328+
static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, JVMFlagOrigin origin);
329+
static jint finalize_vm_init_args();
330330
static bool is_bad_option(const JavaVMOption* option, jboolean ignore, const char* option_type);
331331

332332
static bool is_bad_option(const JavaVMOption* option, jboolean ignore) {
@@ -474,7 +474,7 @@ class Arguments : AllStatic {
474474
static void set_ext_dirs(char *value) { _ext_dirs = os::strdup_check_oom(value); }
475475

476476
// Set up the underlying pieces of the boot class path
477-
static void add_patch_mod_prefix(const char *module_name, const char *path, bool* patch_mod_javabase);
477+
static void add_patch_mod_prefix(const char *module_name, const char *path);
478478
static void set_boot_class_path(const char *value, bool has_jimage) {
479479
// During start up, set by os::set_boot_path()
480480
assert(get_boot_class_path() == nullptr, "Boot class path previously set");

test/hotspot/jtreg/runtime/cds/appcds/CommandLineFlagCombo.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -63,6 +63,7 @@ public class CommandLineFlagCombo {
6363
"-Xint",
6464
"-Xmixed",
6565
"-Xcomp",
66+
"-XX:+SegmentedCodeCache",
6667
};
6768

6869
public static void main(String[] args) throws Exception {

0 commit comments

Comments
 (0)