# HG changeset patch # User johnc # Date 1264805498 28800 # Node ID 745c853ee57f03ab198cd52ee790485938a5ee51 # Parent f3345b7b01b4e9e09bd064a118e3b7a8fb78a5c0 6885297: java -XX:RefDiscoveryPolicy=2 or -XX:TLABWasteTargetPercent=0 cause VM crash Summary: Interval checking is now being performed on the values passed in for these two flags. The current acceptable range for RefDiscoveryPolicy is [0..1], and for TLABWasteTargetPercent it is [1..100]. Reviewed-by: apetrusenko, ysr diff -r f3345b7b01b4 -r 745c853ee57f src/share/vm/includeDB_core --- a/src/share/vm/includeDB_core Wed Jan 27 22:38:37 2010 -0800 +++ b/src/share/vm/includeDB_core Fri Jan 29 14:51:38 2010 -0800 @@ -175,6 +175,7 @@ arguments.cpp management.hpp arguments.cpp oop.inline.hpp arguments.cpp os_.inline.hpp +arguments.cpp referenceProcessor.hpp arguments.cpp universe.inline.hpp arguments.cpp vm_version_.hpp diff -r f3345b7b01b4 -r 745c853ee57f src/share/vm/memory/referenceProcessor.hpp --- a/src/share/vm/memory/referenceProcessor.hpp Wed Jan 27 22:38:37 2010 -0800 +++ b/src/share/vm/memory/referenceProcessor.hpp Fri Jan 29 14:51:38 2010 -0800 @@ -263,10 +263,13 @@ int parallel_gc_threads = 1, bool mt_processing = false, bool discovered_list_needs_barrier = false); + // RefDiscoveryPolicy values - enum { + enum DiscoveryPolicy { ReferenceBasedDiscovery = 0, - ReferentBasedDiscovery = 1 + ReferentBasedDiscovery = 1, + DiscoveryPolicyMin = ReferenceBasedDiscovery, + DiscoveryPolicyMax = ReferentBasedDiscovery }; static void init_statics(); diff -r f3345b7b01b4 -r 745c853ee57f src/share/vm/runtime/arguments.cpp --- a/src/share/vm/runtime/arguments.cpp Wed Jan 27 22:38:37 2010 -0800 +++ b/src/share/vm/runtime/arguments.cpp Fri Jan 29 14:51:38 2010 -0800 @@ -1487,6 +1487,20 @@ //=========================================================================================================== // Parsing of main arguments +bool Arguments::verify_interval(uintx val, uintx min, + uintx max, const char* name) { + // Returns true iff value is in the inclusive interval [min..max] + // false, otherwise. + if (val >= min && val <= max) { + return true; + } + jio_fprintf(defaultStream::error_stream(), + "%s of " UINTX_FORMAT " is invalid; must be between " UINTX_FORMAT + " and " UINTX_FORMAT "\n", + name, val, min, max); + return false; +} + bool Arguments::verify_percentage(uintx value, const char* name) { if (value <= 100) { return true; @@ -1723,6 +1737,16 @@ status = false; } + status = status && verify_interval(RefDiscoveryPolicy, + ReferenceProcessor::DiscoveryPolicyMin, + ReferenceProcessor::DiscoveryPolicyMax, + "RefDiscoveryPolicy"); + + // Limit the lower bound of this flag to 1 as it is used in a division + // expression. + status = status && verify_interval(TLABWasteTargetPercent, + 1, 100, "TLABWasteTargetPercent"); + return status; } diff -r f3345b7b01b4 -r 745c853ee57f src/share/vm/runtime/arguments.hpp --- a/src/share/vm/runtime/arguments.hpp Wed Jan 27 22:38:37 2010 -0800 +++ b/src/share/vm/runtime/arguments.hpp Fri Jan 29 14:51:38 2010 -0800 @@ -336,6 +336,8 @@ static bool is_bad_option(const JavaVMOption* option, jboolean ignore) { return is_bad_option(option, ignore, NULL); } + static bool verify_interval(uintx val, uintx min, + uintx max, const char* name); static bool verify_percentage(uintx value, const char* name); static void describe_range_error(ArgsRange errcode); static ArgsRange check_memory_size(julong size, julong min_size);