aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhseigel <none@none>2012-11-12 15:58:11 -0500
committerhseigel <none@none>2012-11-12 15:58:11 -0500
commit64a56143a4a0e70460a80c260ca2ac5a72a81b96 (patch)
treeee62788cd46568517951a7330bfea35ceca74724 /src
parente67067dfd05f858468af8c9c51a6e3a7ee994182 (diff)
7122219: Passed StringTableSize value not verified
Summary: Check that the values specified for -XX:StringTableSize are within a certain range. Reviewed-by: dholmes, coleenp
Diffstat (limited to 'src')
-rw-r--r--src/share/vm/classfile/symbolTable.hpp11
-rw-r--r--src/share/vm/runtime/arguments.cpp6
-rw-r--r--src/share/vm/runtime/globals.hpp2
-rw-r--r--src/share/vm/runtime/os.cpp4
-rw-r--r--src/share/vm/utilities/globalDefinitions.hpp6
5 files changed, 19 insertions, 10 deletions
diff --git a/src/share/vm/classfile/symbolTable.hpp b/src/share/vm/classfile/symbolTable.hpp
index 98ebcced2..3eee99ddb 100644
--- a/src/share/vm/classfile/symbolTable.hpp
+++ b/src/share/vm/classfile/symbolTable.hpp
@@ -262,19 +262,14 @@ public:
// The string table
static StringTable* the_table() { return _the_table; }
+ // Size of one bucket in the string table. Used when checking for rollover.
+ static uint bucket_size() { return sizeof(HashtableBucket<mtSymbol>); }
+
static void create_table() {
assert(_the_table == NULL, "One string table allowed.");
_the_table = new StringTable();
}
- static void create_table(HashtableBucket<mtSymbol>* t, int length,
- int number_of_entries) {
- assert(_the_table == NULL, "One string table allowed.");
- assert((size_t)length == StringTableSize * sizeof(HashtableBucket<mtSymbol>),
- "bad shared string size.");
- _the_table = new StringTable(t, number_of_entries);
- }
-
// GC support
// Delete pointers to otherwise-unreachable objects.
static void unlink(BoolObjectClosure* cl);
diff --git a/src/share/vm/runtime/arguments.cpp b/src/share/vm/runtime/arguments.cpp
index 5d0fe7ada..24a98be33 100644
--- a/src/share/vm/runtime/arguments.cpp
+++ b/src/share/vm/runtime/arguments.cpp
@@ -24,6 +24,7 @@
#include "precompiled.hpp"
#include "classfile/javaAssertions.hpp"
+#include "classfile/symbolTable.hpp"
#include "compiler/compilerOracle.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/cardTableRS.hpp"
@@ -1844,6 +1845,11 @@ bool Arguments::check_vm_args_consistency() {
status = status && verify_percentage(MinHeapFreeRatio, "MinHeapFreeRatio");
status = status && verify_percentage(MaxHeapFreeRatio, "MaxHeapFreeRatio");
+ // Divide by bucket size to prevent a large size from causing rollover when
+ // calculating amount of memory needed to be allocated for the String table.
+ status = status && verify_interval(StringTableSize, defaultStringTableSize,
+ (max_uintx / StringTable::bucket_size()), "StringTable size");
+
if (MinHeapFreeRatio > MaxHeapFreeRatio) {
jio_fprintf(defaultStream::error_stream(),
"MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or "
diff --git a/src/share/vm/runtime/globals.hpp b/src/share/vm/runtime/globals.hpp
index 62ad97f89..e0e048a2e 100644
--- a/src/share/vm/runtime/globals.hpp
+++ b/src/share/vm/runtime/globals.hpp
@@ -3593,7 +3593,7 @@ class CommandLineFlags {
diagnostic(bool, PrintDTraceDOF, false, \
"Print the DTrace DOF passed to the system for JSDT probes") \
\
- product(uintx, StringTableSize, 1009, \
+ product(uintx, StringTableSize, defaultStringTableSize, \
"Number of buckets in the interned String table") \
\
develop(bool, TraceDefaultMethods, false, \
diff --git a/src/share/vm/runtime/os.cpp b/src/share/vm/runtime/os.cpp
index 56bd82613..34184d928 100644
--- a/src/share/vm/runtime/os.cpp
+++ b/src/share/vm/runtime/os.cpp
@@ -576,7 +576,9 @@ void* os::malloc(size_t size, MEMFLAGS memflags, address caller) {
// if NULL is returned the calling functions assume out of memory.
size = 1;
}
-
+ if (size > size + space_before + space_after) { // Check for rollover.
+ return NULL;
+ }
NOT_PRODUCT(if (MallocVerifyInterval > 0) check_heap());
u_char* ptr = (u_char*)::malloc(size + space_before + space_after);
diff --git a/src/share/vm/utilities/globalDefinitions.hpp b/src/share/vm/utilities/globalDefinitions.hpp
index 0c8ad4af8..9c51c1d58 100644
--- a/src/share/vm/utilities/globalDefinitions.hpp
+++ b/src/share/vm/utilities/globalDefinitions.hpp
@@ -328,6 +328,12 @@ const int max_method_code_size = 64*K - 1; // JVM spec, 2nd ed. section 4.8.1 (
//----------------------------------------------------------------------------------------------------
+// Minimum StringTableSize value
+
+const int defaultStringTableSize=1009;
+
+
+//----------------------------------------------------------------------------------------------------
// HotSwap - for JVMTI aka Class File Replacement and PopFrame
//
// Determines whether on-the-fly class replacement and frame popping are enabled.