diff src/share/vm/runtime/frame.cpp @ 3369:3d2ab563047a

7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method Reviewed-by: kvn, coleenp
author never
date Thu, 12 May 2011 10:29:02 -0700
parents 3cfb240033d1
children b20d64f83668
line wrap: on
line diff
--- a/src/share/vm/runtime/frame.cpp	Mon May 09 19:45:52 2011 -0700
+++ b/src/share/vm/runtime/frame.cpp	Thu May 12 10:29:02 2011 -0700
@@ -1452,13 +1452,26 @@
 
 void FrameValues::print() {
   _values.sort(compare);
-  intptr_t* v0 = _values.at(0).location;
-  intptr_t* v1 = _values.at(_values.length() - 1).location;
+  JavaThread* thread = JavaThread::current();
+
+  // Sometimes values like the fp can be invalid values if the
+  // register map wasn't updated during the walk.  Trim out values
+  // that aren't actually in the stack of the thread.
+  int min_index = 0;
+  int max_index = _values.length() - 1;
+  intptr_t* v0 = _values.at(min_index).location;
+  while (!thread->is_in_stack((address)v0)) {
+    v0 = _values.at(++min_index).location;
+  }
+  intptr_t* v1 = _values.at(max_index).location;
+  while (!thread->is_in_stack((address)v1)) {
+    v1 = _values.at(--max_index).location;
+  }
   intptr_t* min = MIN2(v0, v1);
   intptr_t* max = MAX2(v0, v1);
   intptr_t* cur = max;
   intptr_t* last = NULL;
-  for (int i = _values.length() - 1; i >= 0; i--) {
+  for (int i = max_index; i >= min_index; i--) {
     FrameValue fv = _values.at(i);
     while (cur > fv.location) {
       tty->print_cr(" " INTPTR_FORMAT ": " INTPTR_FORMAT, cur, *cur);