8293006: sun/tools/jhsdb/JStackStressTest.java fails with "UnalignedAddressException: 8baadbabe"

Reviewed-by: dcubed, sspitsyn
This commit is contained in:
Chris Plummer 2022-09-02 16:11:01 +00:00
parent da99e3e829
commit 2baeebbc02
5 changed files with 76 additions and 38 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -190,7 +190,7 @@ public class ObjectHeap {
System.err.println("Oop's klass is " + klass);
}
throw new UnknownOopException();
throw new UnknownOopException(handle.toString());
}
// Print all objects in the object heap

View File

@ -354,7 +354,7 @@ public class JavaThread extends Thread {
VMOopHandle vmOopHandle = VMObjectFactory.newObject(VMOopHandle.class, addr);
obj = vmOopHandle.resolve();
} catch (Exception e) {
e.printStackTrace();
System.out.println("WARNING: could not get Thread object: " + e);
}
return obj;
}
@ -406,7 +406,11 @@ public class JavaThread extends Thread {
public Oop getCurrentParkBlocker() {
Oop threadObj = getThreadObj();
if (threadObj != null) {
return OopUtilities.threadOopGetParkBlocker(threadObj);
try {
return OopUtilities.threadOopGetParkBlocker(threadObj);
} catch (Exception e) {
System.out.println("Could not get current park blocker: " + e);
}
}
return null;
}
@ -502,32 +506,57 @@ public class JavaThread extends Thread {
}
public void printThreadInfoOn(PrintStream out){
Oop threadOop = this.getThreadObj();
String threadName = "<unknown>";
boolean daemon = false;
int priority = java.lang.Thread.MIN_PRIORITY - 1;
String statusName = "<unknown>";
out.print("\"");
out.print(this.getThreadName());
out.print("\" #");
out.print(OopUtilities.threadOopGetTID(threadOop));
if(OopUtilities.threadOopGetDaemon(threadOop)){
out.print(" daemon");
}
out.print(" prio=");
out.print(OopUtilities.threadOopGetPriority(threadOop));
out.print(" tid=");
out.print(this.getAddress());
out.print(" nid=");
out.print(String.format("%d ",this.getOSThread().threadId()));
out.print(getOSThread().getThreadState().getPrintVal());
out.print(" [");
if(this.getLastJavaSP() == null){
out.print(String.format(ADDRESS_FORMAT,0L));
} else {
out.print(this.getLastJavaSP().andWithMask(~0xFFF));
}
out.println("]");
out.print(" java.lang.Thread.State: ");
out.println(OopUtilities.threadOopGetThreadStatusName(threadOop));
out.print(" JavaThread state: _thread_");
out.println(this.getThreadState().toString().toLowerCase());
Oop threadOop = this.getThreadObj();
if (threadOop == null) {
System.out.println("Could not get the java Thread object. Thread info will be limited.");
} else {
// Some of these accesses can throw an Exception if we are in the
// middle of a GC, so be cautious.
try {
threadName = this.getThreadName();
} catch (Exception e) {}
try {
// These all rely on the FieldHolder object, so if one fails, they all fail.
daemon = OopUtilities.threadOopGetDaemon(threadOop);
priority = OopUtilities.threadOopGetPriority(threadOop);
statusName = OopUtilities.threadOopGetThreadStatusName(threadOop);
} catch (Exception e) {}
out.print("\"");
out.print(threadName);
out.print("\" #");
out.print(OopUtilities.threadOopGetTID(threadOop));
if (daemon) {
out.print(" daemon");
}
out.print(" prio=");
if (priority == java.lang.Thread.MIN_PRIORITY - 1) {
out.print("<unknown>");
} else {
out.print(priority);
}
}
out.print(" tid=");
out.print(this.getAddress());
out.print(" nid=");
out.print(String.format("%d ", this.getOSThread().threadId()));
out.print(getOSThread().getThreadState().getPrintVal());
out.print(" [");
if (this.getLastJavaSP() == null) {
out.print(String.format(ADDRESS_FORMAT, 0L));
} else {
out.print(this.getLastJavaSP().andWithMask(~0xFFF));
}
out.println("]");
if (threadOop != null) {
out.print(" java.lang.Thread.State: ");
out.println(statusName);
}
out.print(" JavaThread state: _thread_");
out.println(this.getThreadState().toString().toLowerCase());
}
}

View File

@ -61,7 +61,12 @@ public abstract class JavaVFrame extends VFrame {
lockState, hobj.asLongValue());
Klass klass = Oop.getKlassForOopHandle(hobj);
String klassName = klass.getName().asString();
String klassName;
if (klass != null) {
klassName = klass.getName().asString();
} else {
klassName = "<unknown class>";
}
tty.print("(a ");
if (klassName.equals("java/lang/Class")) {
Oop obj = VM.getVM().getObjectHeap().newOop(hobj);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -78,7 +78,7 @@ public class PStack extends Tool {
try {
DeadlockDetector.print(out);
} catch (Exception exp) {
out.println("can't print deadlock information: " + exp.getMessage());
out.println("can't print deadlock information: " + exp);
}
List<ThreadProxy> l = cdbg.getThreadList();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -62,7 +62,7 @@ public class StackTrace extends Tool {
DeadlockDetector.print(tty);
} catch (Exception exp) {
exp.printStackTrace();
tty.println("Can't print deadlocks:" + exp.getMessage());
tty.println("Can't print deadlocks: " + exp);
}
try {
@ -111,11 +111,15 @@ public class StackTrace extends Tool {
}
tty.println(")");
vf.printLockInfo(tty, count++);
try {
vf.printLockInfo(tty, count++);
} catch (Exception e) {
tty.println("\nCould not print lock info: " + e);
}
}
} catch (Exception e) {
tty.println("Error occurred during stack walking:");
e.printStackTrace();
tty.println("\nError occurred during stack walking:");
e.printStackTrace(tty);
}
tty.println();
if (concurrentLocks) {