Skip to content

Commit

Permalink
Bug 582791 Check DTFJ Image.isTruncated if available
Browse files Browse the repository at this point in the history
Change-Id: I18b2463dda8e5e8abc8728b2da75e8f7a2cbb058
  • Loading branch information
kgibm committed Dec 18, 2023
1 parent 42b5051 commit 35b3ff7
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.Serializable;
import java.lang.ref.SoftReference;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -903,6 +904,23 @@ public void fill(IPreliminaryIndex index, IProgressListener listener) throws Sna
listener.beginTask(MessageFormat.format(Messages.DTFJIndexBuilder_ProcessingImageFromFile, dump), workCount);
int workCountSoFar = 0;

String reliabilityCheck = System.getProperty("reliabilityCheck"); //$NON-NLS-1$
if (reliabilityCheck == null)
{
reliabilityCheck = Platform.getPreferencesService().getString(PLUGIN_ID,
PreferenceConstants.P_RELIABILITY_CHECK, "", null); //$NON-NLS-1$
}

// Set a default preference value
if (!PreferenceConstants.RELIABILITY_FATAL.equals(reliabilityCheck)
&& !PreferenceConstants.RELIABILITY_WARNING.equals(reliabilityCheck)
&& !PreferenceConstants.RELIABILITY_SKIP.equals(reliabilityCheck))
{
reliabilityCheck = PreferenceConstants.RELIABILITY_FATAL;
}

boolean shouldCheckReliability = !PreferenceConstants.RELIABILITY_SKIP.equals(reliabilityCheck);

XSnapshotInfo ifo = index.getSnapshotInfo();

// The dump may have changed, so reread it
Expand Down Expand Up @@ -961,7 +979,56 @@ public void fill(IPreliminaryIndex index, IProgressListener listener) throws Sna
if (rtId instanceof String && ! rtId.equals("")) { //$NON-NLS-1$
runtimeId = (String) rtId;
}


if (shouldCheckReliability)
{
Image image = dtfjInfo.getImage();
if (image != null)
{
// https://eclipse.dev/openj9/docs/api/jdk8/platform/dtfj/com/ibm/dtfj/image/Image.html#isTruncated--
try
{
Method isTruncated = image.getClass().getMethod("isTruncated"); //$NON-NLS-1$
boolean isTruncatedResult = (Boolean) isTruncated.invoke(image);
if (isTruncatedResult)
{
if (PreferenceConstants.RELIABILITY_FATAL.equals(reliabilityCheck))
{
throw new SnapshotException(MessageFormat.format(Messages.DTFJIndexBuilder_Truncated));
}
else if (PreferenceConstants.RELIABILITY_WARNING.equals(reliabilityCheck))
{
listener.sendUserMessage(Severity.WARNING, Messages.DTFJIndexBuilder_Truncated, null);
}
}
}
catch (NoSuchMethodException e)
{
// Older version of DTFJ without this method
}
catch (SecurityException e)
{
// It's not critical to perform this reliability check, so
// ignore this error.
}
catch (IllegalAccessException e)
{
// It's not critical to perform this reliability check, so
// ignore this error.
}
catch (IllegalArgumentException e)
{
// It's not critical to perform this reliability check, so
// ignore this error.
}
catch (InvocationTargetException e)
{
// It's not critical to perform this reliability check, so
// ignore this error.
}
}
}

dtfjInfo = getRuntime(dtfjInfo.getImageFactory(), dtfjInfo.getImage(), runtimeId, listener);
final String actualRuntimeId = dtfjInfo.getRuntimeId();
if (actualRuntimeId != null)
Expand Down Expand Up @@ -993,22 +1060,7 @@ public void fill(IPreliminaryIndex index, IProgressListener listener) throws Sna
}
}

String reliabilityCheck = System.getProperty("reliabilityCheck"); //$NON-NLS-1$
if (reliabilityCheck == null)
{
reliabilityCheck = Platform.getPreferencesService().getString(PLUGIN_ID,
PreferenceConstants.P_RELIABILITY_CHECK, "", null); //$NON-NLS-1$
}

// Set a default preference value
if (!PreferenceConstants.RELIABILITY_FATAL.equals(reliabilityCheck)
&& !PreferenceConstants.RELIABILITY_WARNING.equals(reliabilityCheck)
&& !PreferenceConstants.RELIABILITY_SKIP.equals(reliabilityCheck))
{
reliabilityCheck = PreferenceConstants.RELIABILITY_FATAL;
}

if (!PreferenceConstants.RELIABILITY_SKIP.equals(reliabilityCheck))
if (shouldCheckReliability)
{
DumpReliabilityResult reliabilityResult = checkDumpReliability(ifo, listener);
DumpReliability reliability = reliabilityResult.getValue();
Expand Down Expand Up @@ -2767,7 +2819,7 @@ else if (majorVersion == 8 && build.contains("+")) //$NON-NLS-1$
dtfjImplementation, fileType));
}
}

// This is a best-effort check so it's okay to use known class names:
// com.ibm.j9ddr.view.dtfj.image.J9DDRImage
String imageClassName = dtfjInfo.getImage().getClass().getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public class Messages extends NLS
public static String DTFJIndexBuilder_ThreadStateNotFound;
public static String DTFJIndexBuilder_TookmsToGetImageFromFile;
public static String DTFJIndexBuilder_TookmsToParseFile;
public static String DTFJIndexBuilder_Truncated;
public static String DTFJIndexBuilder_UnableToFindClassLoader;
public static String DTFJIndexBuilder_UnableToFindDTFJForFormat;
public static String DTFJIndexBuilder_UnableToFindJavaRuntime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ DTFJIndexBuilder_UnableToFindDTFJForFormat=Unable to find DTFJ for format {0}
DTFJIndexBuilder_UsingAddressForThreadName=Using address {0} for thread {1}
DTFJIndexBuilder_Runtime_Description=Address space ID: {0} \nProcess ID: {1} \nRuntime: {2}
DTFJIndexBuilder_ProblemGettingObjectNotArray=Object at {0} is not an array but its registered class {1} is an array type. This may be a dump taken in the middle of a garbage collection which is unreliable, or heap corruption
DTFJIndexBuilder_Truncated=The dump is truncated. Common causes include insufficient core or file ulimits on POSIX operating systems, exhausted disk space in the core dump directory, a Linux piped core dump processing program such as systemd-coredump with file size truncation (see kernel.core_pattern), or the AIX fullcore option is not set.
DTFJPreferencePage_AllMethods=Stack frames as pseudo-objects and all methods as pseudo-classes
DTFJPreferencePage_Description=Configuration used for parsing DTFJ dumps from IBM virtual machines for Java.
DTFJPreferencePage_MethodsAsClasses=Whether to treat stack frames as pseudo-objects, methods as pseudo-classes and methods as the type of stack frames
Expand Down

0 comments on commit 35b3ff7

Please sign in to comment.