6885308: The incorrect -XX:StackRedPages, -XX:StackShadowPages, -XX:StackYellowPages could cause VM crash

Thu, 19 Aug 2010 14:23:59 -0400

author
ptisnovs
date
Thu, 19 Aug 2010 14:23:59 -0400
changeset 2099
f8c5d1bdaad4
parent 2050
21e519b91576
child 2100
ebfb7c68865e

6885308: The incorrect -XX:StackRedPages, -XX:StackShadowPages, -XX:StackYellowPages could cause VM crash
Summary: Test minimal stack sizes given (also fixed linux compilation error)
Reviewed-by: never, phh, coleenp

src/share/vm/memory/allocation.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/arguments.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/arguments.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/memory/allocation.cpp	Fri Aug 13 07:33:20 2010 -0700
     1.2 +++ b/src/share/vm/memory/allocation.cpp	Thu Aug 19 14:23:59 2010 -0400
     1.3 @@ -58,7 +58,7 @@
     1.4  void ResourceObj::operator delete(void* p) {
     1.5    assert(((ResourceObj *)p)->allocated_on_C_heap(),
     1.6           "delete only allowed for C_HEAP objects");
     1.7 -  DEBUG_ONLY(((ResourceObj *)p)->_allocation = badHeapOopVal;)
     1.8 +  DEBUG_ONLY(((ResourceObj *)p)->_allocation = (uintptr_t)badHeapOopVal;)
     1.9    FreeHeap(p);
    1.10  }
    1.11  
    1.12 @@ -104,7 +104,7 @@
    1.13  ResourceObj::~ResourceObj() {
    1.14      // allocated_on_C_heap() also checks that encoded (in _allocation) address == this.
    1.15      if (!allocated_on_C_heap()) {  // ResourceObj::delete() zaps _allocation for C_heap.
    1.16 -      _allocation = badHeapOopVal; // zap type
    1.17 +      _allocation = (uintptr_t)badHeapOopVal; // zap type
    1.18      }
    1.19  }
    1.20  #endif // ASSERT
     2.1 --- a/src/share/vm/runtime/arguments.cpp	Fri Aug 13 07:33:20 2010 -0700
     2.2 +++ b/src/share/vm/runtime/arguments.cpp	Thu Aug 19 14:23:59 2010 -0400
     2.3 @@ -1559,6 +1559,18 @@
     2.4    return false;
     2.5  }
     2.6  
     2.7 +bool Arguments::verify_min_value(intx val, intx min, const char* name) {
     2.8 +  // Returns true if given value is greater than specified min threshold
     2.9 +  // false, otherwise.
    2.10 +  if (val >= min ) {
    2.11 +      return true;
    2.12 +  }
    2.13 +  jio_fprintf(defaultStream::error_stream(),
    2.14 +              "%s of " INTX_FORMAT " is invalid; must be greater than " INTX_FORMAT "\n",
    2.15 +              name, val, min);
    2.16 +  return false;
    2.17 +}
    2.18 +
    2.19  bool Arguments::verify_percentage(uintx value, const char* name) {
    2.20    if (value <= 100) {
    2.21      return true;
    2.22 @@ -1611,6 +1623,16 @@
    2.23    return status;
    2.24  }
    2.25  
    2.26 +// Check stack pages settings
    2.27 +bool Arguments::check_stack_pages()
    2.28 +{
    2.29 +  bool status = true;
    2.30 +  status = status && verify_min_value(StackYellowPages, 1, "StackYellowPages");
    2.31 +  status = status && verify_min_value(StackRedPages, 1, "StackRedPages");
    2.32 +  status = status && verify_min_value(StackShadowPages, 1, "StackShadowPages");
    2.33 +  return status;
    2.34 +}
    2.35 +
    2.36  // Check the consistency of vm_init_args
    2.37  bool Arguments::check_vm_args_consistency() {
    2.38    // Method for adding checks for flag consistency.
    2.39 @@ -1723,6 +1745,7 @@
    2.40    }
    2.41  
    2.42    status = status && check_gc_consistency();
    2.43 +  status = status && check_stack_pages();
    2.44  
    2.45    if (_has_alloc_profile) {
    2.46      if (UseParallelGC || UseParallelOldGC) {
     3.1 --- a/src/share/vm/runtime/arguments.hpp	Fri Aug 13 07:33:20 2010 -0700
     3.2 +++ b/src/share/vm/runtime/arguments.hpp	Thu Aug 19 14:23:59 2010 -0400
     3.3 @@ -338,6 +338,7 @@
     3.4    }
     3.5    static bool verify_interval(uintx val, uintx min,
     3.6                                uintx max, const char* name);
     3.7 +  static bool verify_min_value(intx val, intx min, const char* name);
     3.8    static bool verify_percentage(uintx value, const char* name);
     3.9    static void describe_range_error(ArgsRange errcode);
    3.10    static ArgsRange check_memory_size(julong size, julong min_size);
    3.11 @@ -400,6 +401,8 @@
    3.12    static bool check_gc_consistency();
    3.13    // Check consistecy or otherwise of VM argument settings
    3.14    static bool check_vm_args_consistency();
    3.15 +  // Check stack pages settings
    3.16 +  static bool check_stack_pages();
    3.17    // Used by os_solaris
    3.18    static bool process_settings_file(const char* file_name, bool should_exist, jboolean ignore_unrecognized);
    3.19  

mercurial