# HG changeset patch # User never # Date 1222372251 25200 # Node ID 885fe0f958282a48bdbc97791f74e398fa14d31d # Parent 5f85534046c2c8d8129a5b198099fb41840bdd32 6744783: HotSpot segfaults if given -XX options with an empty string argument Reviewed-by: kamg, kvn Contributed-by: volker.simonis@gmail.com diff -r 5f85534046c2 -r 885fe0f95828 src/share/vm/prims/jvmtiTrace.cpp --- a/src/share/vm/prims/jvmtiTrace.cpp Wed Sep 24 15:56:36 2008 -0700 +++ b/src/share/vm/prims/jvmtiTrace.cpp Thu Sep 25 12:50:51 2008 -0700 @@ -73,7 +73,7 @@ const char *very_end; const char *curr; - if (strlen(TraceJVMTI)) { + if (TraceJVMTI != NULL) { curr = TraceJVMTI; } else { curr = ""; // hack in fixed tracing here diff -r 5f85534046c2 -r 885fe0f95828 src/share/vm/runtime/globals.cpp --- a/src/share/vm/runtime/globals.cpp Wed Sep 24 15:56:36 2008 -0700 +++ b/src/share/vm/runtime/globals.cpp Thu Sep 25 12:50:51 2008 -0700 @@ -355,8 +355,11 @@ if (result == NULL) return false; if (!result->is_ccstr()) return false; ccstr old_value = result->get_ccstr(); - char* new_value = NEW_C_HEAP_ARRAY(char, strlen(*value)+1); - strcpy(new_value, *value); + char* new_value = NULL; + if (*value != NULL) { + new_value = NEW_C_HEAP_ARRAY(char, strlen(*value)+1); + strcpy(new_value, *value); + } result->set_ccstr(new_value); if (result->origin == DEFAULT && old_value != NULL) { // Prior value is NOT heap allocated, but was a literal constant. diff -r 5f85534046c2 -r 885fe0f95828 src/share/vm/runtime/globals.hpp --- a/src/share/vm/runtime/globals.hpp Wed Sep 24 15:56:36 2008 -0700 +++ b/src/share/vm/runtime/globals.hpp Thu Sep 25 12:50:51 2008 -0700 @@ -692,7 +692,7 @@ diagnostic(bool, PrintAssembly, false, \ "Print assembly code (using external disassembler.so)") \ \ - diagnostic(ccstr, PrintAssemblyOptions, false, \ + diagnostic(ccstr, PrintAssemblyOptions, NULL, \ "Options string passed to disassembler.so") \ \ diagnostic(bool, PrintNMethods, false, \ @@ -833,7 +833,7 @@ "Use LWP-based instead of libthread-based synchronization " \ "(SPARC only)") \ \ - product(ccstr, SyncKnobs, "", \ + product(ccstr, SyncKnobs, NULL, \ "(Unstable) Various monitor synchronization tunables") \ \ product(intx, EmitSync, 0, \ @@ -1017,7 +1017,7 @@ notproduct(bool, TraceJVMCalls, false, \ "Trace JVM calls") \ \ - product(ccstr, TraceJVMTI, "", \ + product(ccstr, TraceJVMTI, NULL, \ "Trace flags for JVMTI functions and events") \ \ /* This option can change an EMCP method into an obsolete method. */ \