Program: 150180
Project: 150180
Buggy source:
/** 
 * Really Print the stack trace. Delegate the actual printing of the stack trace to the VM_CompiledMethod; this means it will deal with inlining by the opt compiler in a sensible fashion.  This is not ever supposed to throw an OutOfMemoryError.  But if it should ever happen to do so, we will catch it in the caller, print().
 * @param out PrintLN to print on.
 * @param trigger The Throwable that caused the stack trace.Used to elide internal details from the stack trace. If null, then we print a full stack trace, without eliding the methods used internally to gather the stack trace.
 */
private void print4Real(PrintLN out,Throwable trigger,int depth){
  if (depth > printingMaxDepth) {
    VM.sysWriteln("String_Node_Str",depth,"String_Node_Str",traceIndex);
    return;
  }
  int foundTriggerAt=-1;
  int lastFrame=compiledMethods.length - 1;
  lastFrame-=1;
  if (trigger != null) {
    Class triggerClass=trigger.getClass();
    for (int i=0; i <= lastFrame; ++i) {
      VM_CompiledMethod cm=compiledMethods[i];
      if (cm == null || cm.getCompilerType() == VM_CompiledMethod.TRAP)       continue;
      VM_Method m=cm.getMethod();
      VM_Class frameVM_Class=m.getDeclaringClass();
      if (frameVM_Class.getClassForType() == triggerClass) {
        foundTriggerAt=i;
        break;
      }
    }
  }
  while (foundTriggerAt + 2 < compiledMethods.length && compiledMethods[foundTriggerAt + 1] == null) {
    foundTriggerAt++;
  }
  VM_CompiledMethod bottom=compiledMethods[foundTriggerAt + 1];
  if (bottom.getMethod() == VM_Entrypoints.deliverHardwareExceptionMethod) {
    foundTriggerAt+=2;
  }
  int nPrinted=0;
  for (int i=foundTriggerAt + 1; i <= lastFrame; ++i, ++nPrinted) {
    VM_CompiledMethod cm=compiledMethods[i];
    if (nPrinted == elideAfterThisManyFrames) {
      int oldIndex=i;
      int newIndex=lastFrame - 9;
      if (newIndex > oldIndex) {
        i=newIndex;
        try {
          out.print("String_Node_Str");
          out.print(newIndex - oldIndex);
          out.println("String_Node_Str");
        }
 catch (        OutOfMemoryError e) {
          trigger.tallyOutOfMemoryError();
          if (out.isSysWrite()) {
            VM.sysWriteln("String_Node_Str");
          }
 else {
            VM.sysWriteln("String_Node_Str");
            VM.sysWriteln("String_Node_Str");
            throw e;
          }
        }
      }
    }
    try {
      if (cm == null) {
        out.println("String_Node_Str");
      }
 else {
        cm.printStackTrace(offsets[i],out);
      }
    }
 catch (    OutOfMemoryError e) {
      trigger.tallyOutOfMemoryError();
      if (out.isSysWrite()) {
        VM.sysWriteln("String_Node_Str");
      }
 else {
        try {
          out.flush();
          VM.sysWriteln();
        }
 catch (        OutOfMemoryError e2) {
          trigger.tallyOutOfMemoryError();
          VM.sysWriteln();
          VM.sysWriteln("String_Node_Str");
        }
        VM.sysWriteln("String_Node_Str");
        throw e;
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Really Print the stack trace. Delegate the actual printing of the stack trace to the VM_CompiledMethod; this means it will deal with inlining by the opt compiler in a sensible fashion.  This is not ever supposed to throw an OutOfMemoryError.  But if it should ever happen to do so, we will catch it in the caller, print().
 * @param out PrintLN to print on.
 * @param trigger The Throwable that caused the stack trace.Used to elide internal details from the stack trace. If null, then we print a full stack trace, without eliding the methods used internally to gather the stack trace.
 */
private void print4Real(PrintLN out,Throwable trigger,int depth){
  if (depth > printingMaxDepth) {
    VM.sysWriteln("String_Node_Str",depth,"String_Node_Str",traceIndex);
    return;
  }
  int foundTriggerAt=-1;
  int lastFrame=compiledMethods.length - 1;
  for (; lastFrame > 0; --lastFrame) {
    VM_Method m=compiledMethods[lastFrame].getMethod();
    if (m == VM_Entrypoints.threadStartoffMethod)     continue;
    if (m == VM_Entrypoints.threadRunMethod)     continue;
    if (m == VM_Entrypoints.mainThreadRunMethod)     continue;
    break;
  }
  if (trigger != null) {
    Class triggerClass=trigger.getClass();
    for (int i=0; i <= lastFrame; ++i) {
      VM_CompiledMethod cm=compiledMethods[i];
      if (cm == null || cm.getCompilerType() == VM_CompiledMethod.TRAP)       continue;
      VM_Method m=cm.getMethod();
      VM_Class frameVM_Class=m.getDeclaringClass();
      if (frameVM_Class.getClassForType() == triggerClass) {
        foundTriggerAt=i;
        break;
      }
    }
  }
  while (foundTriggerAt + 2 < compiledMethods.length && compiledMethods[foundTriggerAt + 1] == null) {
    foundTriggerAt++;
  }
  VM_CompiledMethod bottom=compiledMethods[foundTriggerAt + 1];
  if (bottom.getMethod() == VM_Entrypoints.deliverHardwareExceptionMethod) {
    foundTriggerAt+=2;
  }
  int nPrinted=0;
  for (int i=foundTriggerAt + 1; i <= lastFrame; ++i, ++nPrinted) {
    VM_CompiledMethod cm=compiledMethods[i];
    if (nPrinted == elideAfterThisManyFrames) {
      int oldIndex=i;
      int newIndex=lastFrame - 9;
      if (newIndex > oldIndex) {
        i=newIndex;
        try {
          out.print("String_Node_Str");
          out.print(newIndex - oldIndex);
          out.println("String_Node_Str");
        }
 catch (        OutOfMemoryError e) {
          trigger.tallyOutOfMemoryError();
          if (out.isSysWrite()) {
            VM.sysWriteln("String_Node_Str");
          }
 else {
            VM.sysWriteln("String_Node_Str");
            VM.sysWriteln("String_Node_Str");
            throw e;
          }
        }
      }
    }
    try {
      if (cm == null) {
        out.println("String_Node_Str");
      }
 else {
        cm.printStackTrace(offsets[i],out);
      }
    }
 catch (    OutOfMemoryError e) {
      trigger.tallyOutOfMemoryError();
      if (out.isSysWrite()) {
        VM.sysWriteln("String_Node_Str");
      }
 else {
        try {
          out.flush();
          VM.sysWriteln();
        }
 catch (        OutOfMemoryError e2) {
          trigger.tallyOutOfMemoryError();
          VM.sysWriteln();
          VM.sysWriteln("String_Node_Str");
        }
        VM.sysWriteln("String_Node_Str");
        throw e;
      }
    }
  }
}