295329
--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/PStack.java	2012-04-06 02:26:33.322164601 +0200
295329
+++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/PStack.java	2012-04-06 02:26:57.958514071 +0200
295329
@@ -1,5 +1,6 @@
295329
 /*
295329
  * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
295329
+ * Copyright (c) 2012, Red Hat Inc.
295329
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
295329
  *
295329
  * This code is free software; you can redistribute it and/or modify it
295329
@@ -84,7 +85,8 @@
295329
                out.print("----------------- ");
295329
                out.print(th);
295329
                out.println(" -----------------");
295329
-               while (f != null) {
295329
+               int maxStack = 256;
295329
+               while (f != null && maxStack-- > 0) {
295329
                   ClosestSymbol sym = f.closestSymbolToPC();
295329
                   Address pc = f.pc();
295329
                   out.print(pc + "\t");
295329
@@ -158,10 +160,19 @@
295329
                         printUnknown(out);
295329
                      }
295329
                   }
295329
+                  Address oldPC = f.pc();
295329
+                  Address oldFP = f.localVariableBase();
295329
                   f = f.sender(th);
295329
+                  if (f != null
295329
+                      && oldPC.equals(f.pc())
295329
+                      && oldFP.equals(f.localVariableBase())) {
295329
+                      // We didn't make any progress
295329
+                      f = null;
295329
+                  }
295329
                }
295329
             } catch (Exception exp) {
295329
-               exp.printStackTrace();
295329
+               // exp.printStackTrace();
295329
+               out.println("bad stack: " + exp);
295329
                // continue, may be we can do a better job for other threads
295329
             }
295329
             if (isJava && concurrentLocks) {