use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class J9JavaVMHelper method getSystemProperties.
public static Properties getSystemProperties(J9JavaVMPointer vm) throws CorruptDataException {
Properties result = new Properties();
Pool<J9VMSystemPropertyPointer> sysprops = Pool.fromJ9Pool(vm.systemProperties(), J9VMSystemPropertyPointer.class);
Iterator<J9VMSystemPropertyPointer> syspropsIterator = sysprops.iterator();
int count = 0;
while (syspropsIterator.hasNext()) {
J9VMSystemPropertyPointer prop = syspropsIterator.next();
// Iterator may return null if corrupt data was found.
if (prop != null) {
String name = null;
try {
name = prop.name().getCStringAtOffset(0);
} catch (CorruptDataException e) {
name = "Corrupt System Property[" + count + "]";
}
String value = null;
try {
value = prop.value().getCStringAtOffset(0);
} catch (CorruptDataException e) {
value = "Corrupt Value";
}
result.setProperty(name, value);
}
count++;
}
return result;
}
use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class J9MemTagHelper method j9mem_check_tags.
/**
* Performs validation checks on the memory block starting at memoryPointer.
*
* The memory passed in could fall into one of three categories:
* 1) It could be a valid J9MemTag region with valid headers and footers
* 2) It could be not be a J9MemTag region
* 3) It could be a J9MemTag region with some corruption in either the header, footer or padding
*
* @param[in] portLibrary The port library
* @param[in] memoryPointer address returned by @ref j9mem_allocate_memory()
*
* @throws CorruptDataException if the tags are corrupted, or the memory is inaccessible. (Option 3)
* @return J9PORT_MEMTAG_NOT_A_TAG if memoryPointer address is not a tag
* J9PORT_MEMTAG_HEADER_TAG_CORRUPTED if memoryPointer address is valid tag region but header tag is corrupted.
* J9PORT_MEMTAG_FOOTER_TAG_CORRUPTED if memoryPointer address is valid tag region but footer tag is corrupted.
* J9PORT_MEMTAG_FOOTER_PADDING_CORRUPTED if memoryPointer address is valid tag region but footer padding is corrupted.
* J9PORT_MEMTAG_VALID_TAG if memoryPointer address is valid tag and header/footer are not corrupted.
* @note memoryPointer may not be NULL.
*/
public static IDATA j9mem_check_tags(VoidPointer memoryPointer, long headerEyecatcher, long footerEyecatcher) throws J9MemTagCheckError {
J9MemTagPointer headerTagAddress, footerTagAddress = J9MemTagPointer.NULL;
headerTagAddress = j9mem_get_header_tag(memoryPointer);
try {
footerTagAddress = j9mem_get_footer_tag(headerTagAddress);
checkTagSumCheck(headerTagAddress, headerEyecatcher);
} catch (J9MemTagCheckError e) {
/* Corruption here either means the header tag is mangled, or the header eyecatcher isn't actually the start of a
* J9MemTag block.
*
* If we can find a valid footerTag, then we'll believe this is a mangled header.
*/
try {
if (checkEyecatcher(footerTagAddress, footerEyecatcher)) {
/* Footer eyecatcher is valid - header tag is corrupt */
throw e;
} else {
/* Footer eyecatcher is invalid - this isn't a memory tag */
return J9PORT_MEMTAG_NOT_A_TAG;
}
} catch (CorruptDataException e1) {
/* Can't read the footer tag - assume memoryPointer isn't a tag */
return J9PORT_MEMTAG_NOT_A_TAG;
}
} catch (CorruptDataException e) {
/* CorruptDataException here will mean MemoryFault. Which means we can't read the
* entire header tag - so we assume this isn't a valid J9MemTag
*/
return J9PORT_MEMTAG_NOT_A_TAG;
}
try {
checkTagSumCheck(footerTagAddress, footerEyecatcher);
} catch (J9MemTagCheckError e) {
if (headerEyecatcher == J9MEMTAG_EYECATCHER_FREED_HEADER && footerEyecatcher == J9MEMTAG_EYECATCHER_FREED_FOOTER) {
/* When dealing with already freed memory, it is reasonable to accept
* a block that is missing the footer instead of throwing an exception.
*/
return J9PORT_MEMTAG_FOOTER_TAG_CORRUPTED;
} else {
throw e;
}
} catch (CorruptDataException e) {
/* If we got here, the header was valid. A memory fault here suggests
* we're missing the storage for the footer - which is corruption
*/
throw new J9MemTagCheckError(headerTagAddress, e);
}
try {
checkPadding(headerTagAddress);
} catch (J9MemTagCheckError e) {
if (headerEyecatcher == J9MEMTAG_EYECATCHER_FREED_HEADER && footerEyecatcher == J9MEMTAG_EYECATCHER_FREED_FOOTER) {
/* When dealing with already freed memory, it is reasonable to accept
* a block that is missing the footer instead of throwing an exception.
*/
return J9PORT_MEMTAG_FOOTER_PADDING_CORRUPTED;
} else {
throw e;
}
} catch (CorruptDataException e) {
/* If we got here, the header was valid. A memory fault here suggests
* we're missing the storage for the padding - which is corruption
*/
throw new J9MemTagCheckError(headerTagAddress, e);
}
return J9PORT_MEMTAG_VALID_TAG;
}
use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class FindVMTask method run.
/* (non-Javadoc)
* @see com.ibm.j9ddr.IBootstrapRunnable#run(com.ibm.j9ddr.IVMData, java.lang.Object[])
*/
public void run(IVMData vmData, Object[] userData) {
long[] passBackArray = (long[]) userData[0];
String vmAddressString = System.getProperty(J9VM_ADDRESS_PROPERTY);
if (vmAddressString != null) {
long address = 0;
try {
if (vmAddressString.startsWith("0x")) {
address = Long.parseLong(vmAddressString.substring(2), 16);
} else {
address = Long.parseLong(vmAddressString);
}
} catch (NumberFormatException nfe) {
logger.warning("System property " + J9VM_ADDRESS_PROPERTY + " does not contain a valid pointer address, found: " + vmAddressString);
throw nfe;
}
logger.warning("FindVMTask forcing J9JavaVMPointer to address from system property " + J9VM_ADDRESS_PROPERTY + " : " + vmAddressString);
// Override the cached version from J9RASHelper as well.
J9JavaVMPointer vm = J9JavaVMPointer.cast(address);
J9RASHelper.setCachedVM(vm);
passBackArray[0] = vm.getAddress();
} else {
try {
passBackArray[0] = DataType.getJ9RASPointer().vm().longValue();
} catch (CorruptDataException e) {
throw new RuntimeException(e);
}
}
logger.fine("FindVMTask passing back J9JavaVMPointer: 0x" + Long.toHexString(passBackArray[0]));
}
use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class ThreadsCommand method debugEventData.
private void debugEventData(PrintStream out) throws DDRInteractiveCommandException {
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
J9VMThreadPointer mainThread = vm.mainThread();
if (mainThread.notNull()) {
J9VMThreadPointer threadCursor = vm.mainThread();
do {
//
out.append(String.format(" !j9vmthread 0x%s %s %s %s %s %s %s %s %s", Long.toHexString(threadCursor.getAddress()), Long.toHexString(threadCursor.debugEventData1().longValue()), Long.toHexString(threadCursor.debugEventData2().longValue()), Long.toHexString(threadCursor.debugEventData3().longValue()), Long.toHexString(threadCursor.debugEventData4().longValue()), Long.toHexString(threadCursor.debugEventData5().longValue()), Long.toHexString(threadCursor.debugEventData6().longValue()), Long.toHexString(threadCursor.debugEventData7().longValue()), Long.toHexString(threadCursor.debugEventData8().longValue())));
out.append(nl);
threadCursor = threadCursor.linkNext();
} while (!threadCursor.eq(mainThread));
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class LinearDumper method addSlot.
public void addSlot(StructurePointer clazz, SlotType type, AbstractPointer slotPtr, String slotName, String additionalInfo) throws CorruptDataException {
try {
J9ROMNameAndSignaturePointer nas;
long offset;
/* The slots of the type J9_ROM_UTF8 are changed to have 2 slots:
* -J9_SRP_TO_STRING
* -J9_ROM_UTF8
* This is done because we want to print the SRP field and also print
* the UTF8 it is pointing to */
switch(type) {
case J9_ROM_UTF8:
offset = slotPtr.getAddress() - clazz.getAddress();
classRegions.add(new J9ClassRegion(slotPtr, SlotType.J9_SRP_TO_STRING, slotName, additionalInfo, type.getSize(), offset, true));
VoidPointer srp = SelfRelativePointer.cast(slotPtr).get();
addUTF8Region(clazz, slotName, additionalInfo, srp);
break;
case J9_UTF8:
addUTF8Region(clazz, slotName, additionalInfo, slotPtr);
break;
/* The fields of the type J9_SRPNAS or J9_SRP are changed to have 2 J9_ROM_UTF8
* fields for their name and signature separated. */
case J9_SRPNAS:
nas = J9ROMNameAndSignaturePointer.cast(SelfRelativePointer.cast(slotPtr).get());
if (nas.notNull()) {
addSlot(clazz, SlotType.J9_ROM_UTF8, nas.nameEA(), "name");
addSlot(clazz, SlotType.J9_ROM_UTF8, nas.signatureEA(), "signature");
}
/* Since it is a SRP to a NAS, also print the SRP field. */
addSlot(clazz, SlotType.J9_SRP, slotPtr, "cpFieldNAS");
break;
case J9_NAS:
nas = J9ROMNameAndSignaturePointer.cast(slotPtr);
addSlot(clazz, SlotType.J9_ROM_UTF8, nas.nameEA(), "name");
addSlot(clazz, SlotType.J9_ROM_UTF8, nas.signatureEA(), "signature");
break;
case J9_IntermediateClassData:
offset = slotPtr.getAddress() - clazz.getAddress();
classRegions.add(new J9ClassRegion(slotPtr, type, slotName, additionalInfo, ((J9ROMClassPointer) clazz).intermediateClassDataLength().longValue(), offset, true));
break;
default:
offset = slotPtr.getAddress() - clazz.getAddress();
classRegions.add(new J9ClassRegion(slotPtr, type, slotName, additionalInfo, type.getSize(), offset, true));
break;
}
} catch (Exception e) {
}
}
Aggregations