Program: 150031
Project: 150031
Buggy source:
/** 
 * Deliver a hardware exception to current java thread.
 * @param trapCode code indicating kind of exception that was trapped (see TRAP_xxx, above)
 * @param trapInfo array subscript (for array bounds trap, only)does not return  (stack is unwound, starting at trap site, and execution resumes in a catch block somewhere up the stack) /or/  execution resumes at instruction following trap  (for TRAP_STACK_OVERFLOW) <p> Note:     Control reaches here by the actions of an  external "C" signal handler which saves the register state of the trap site into the  "hardwareExceptionRegisters" field of the current  VM_Thread object.  The signal handler also inserts a <hardware trap> frame onto the stack immediately above this frame, for use by  VM_HardwareTrapGCMapIterator during garbage collection.
 */
static void deliverHardwareException(int trapCode,int trapInfo){
  VM_Thread myThread=VM_Thread.getCurrentThread();
  VM_Registers exceptionRegisters=myThread.hardwareExceptionRegisters;
  if ((trapCode == TRAP_STACK_OVERFLOW || trapCode == TRAP_JNI_STACK) && myThread.stack.length < (STACK_SIZE_MAX >> LOG_BYTES_IN_ADDRESS) && !myThread.hasNativeStackFrame()) {
    if (trapCode == TRAP_JNI_STACK) {
      VM_Thread.resizeCurrentStack(myThread.stack.length + STACK_SIZE_JNINATIVE_GROW,exceptionRegisters);
    }
 else {
      VM_Thread.resizeCurrentStack(myThread.stack.length + STACK_SIZE_GROW,exceptionRegisters);
    }
    if (VM.VerifyAssertions)     VM._assert(exceptionRegisters.inuse == true);
    exceptionRegisters.inuse=false;
    VM_Magic.restoreHardwareExceptionState(exceptionRegisters);
    if (VM.VerifyAssertions)     VM._assert(NOT_REACHED);
  }
  if (VM.ForceFrequentGC && VM_Scheduler.allProcessorsInitialized) {
    VM.sysWrite("String_Node_Str");
    MM_Interface.gc();
  }
  Throwable exceptionObject;
switch (trapCode) {
case TRAP_NULL_POINTER:
    exceptionObject=new java.lang.NullPointerException();
  break;
case TRAP_ARRAY_BOUNDS:
exceptionObject=new java.lang.ArrayIndexOutOfBoundsException(trapInfo);
break;
case TRAP_DIVIDE_BY_ZERO:
exceptionObject=new java.lang.ArithmeticException();
break;
case TRAP_STACK_OVERFLOW:
case TRAP_JNI_STACK:
exceptionObject=new java.lang.StackOverflowError();
break;
case TRAP_CHECKCAST:
exceptionObject=new java.lang.ClassCastException();
break;
case TRAP_MUST_IMPLEMENT:
exceptionObject=new java.lang.IncompatibleClassChangeError();
break;
case TRAP_STORE_CHECK:
exceptionObject=new java.lang.ArrayStoreException();
break;
default :
exceptionObject=new java.lang.UnknownError();
VM_Scheduler.traceback("String_Node_Str");
break;
}
VM.disableGC();
deliverException(exceptionObject,exceptionRegisters);
}

Fixed version (ground truth):
/** 
 * Deliver a hardware exception to current java thread.
 * @param trapCode code indicating kind of exception that was trapped (see TRAP_xxx, above)
 * @param trapInfo array subscript (for array bounds trap, only)does not return  (stack is unwound, starting at trap site, and execution resumes in a catch block somewhere up the stack) /or/  execution resumes at instruction following trap  (for TRAP_STACK_OVERFLOW) <p> Note:     Control reaches here by the actions of an  external "C" signal handler which saves the register state of the trap site into the  "hardwareExceptionRegisters" field of the current  VM_Thread object.  The signal handler also inserts a <hardware trap> frame onto the stack immediately above this frame, for use by  VM_HardwareTrapGCMapIterator during garbage collection.
 */
static void deliverHardwareException(int trapCode,int trapInfo){
  VM_Thread myThread=VM_Thread.getCurrentThread();
  VM_Registers exceptionRegisters=myThread.hardwareExceptionRegisters;
  if ((trapCode == TRAP_STACK_OVERFLOW || trapCode == TRAP_JNI_STACK) && myThread.stack.length < (STACK_SIZE_MAX >> LOG_BYTES_IN_ADDRESS) && !myThread.hasNativeStackFrame()) {
    if (trapCode == TRAP_JNI_STACK) {
      VM_Thread.resizeCurrentStack(myThread.stack.length + STACK_SIZE_JNINATIVE_GROW,exceptionRegisters);
    }
 else {
      VM_Thread.resizeCurrentStack(myThread.stack.length + STACK_SIZE_GROW,exceptionRegisters);
    }
    if (VM.VerifyAssertions)     VM._assert(exceptionRegisters.inuse == true);
    exceptionRegisters.inuse=false;
    VM_Magic.restoreHardwareExceptionState(exceptionRegisters);
    if (VM.VerifyAssertions)     VM._assert(NOT_REACHED);
  }
  if (VM.ForceFrequentGC && VM_Scheduler.allProcessorsInitialized) {
    VM.sysWrite("String_Node_Str");
    System.gc();
  }
  Throwable exceptionObject;
switch (trapCode) {
case TRAP_NULL_POINTER:
    exceptionObject=new java.lang.NullPointerException();
  break;
case TRAP_ARRAY_BOUNDS:
exceptionObject=new java.lang.ArrayIndexOutOfBoundsException(trapInfo);
break;
case TRAP_DIVIDE_BY_ZERO:
exceptionObject=new java.lang.ArithmeticException();
break;
case TRAP_STACK_OVERFLOW:
case TRAP_JNI_STACK:
exceptionObject=new java.lang.StackOverflowError();
break;
case TRAP_CHECKCAST:
exceptionObject=new java.lang.ClassCastException();
break;
case TRAP_MUST_IMPLEMENT:
exceptionObject=new java.lang.IncompatibleClassChangeError();
break;
case TRAP_STORE_CHECK:
exceptionObject=new java.lang.ArrayStoreException();
break;
default :
exceptionObject=new java.lang.UnknownError();
VM_Scheduler.traceback("String_Node_Str");
break;
}
VM.disableGC();
deliverException(exceptionObject,exceptionRegisters);
}