Program: 149873
Project: 149873
Buggy source:
/** 
 * Terminate execution of current thread by abandoning all references to it and resuming execution in some other (ready) thread.
 */
@Interruptible public final void terminate(){
  if (VM.VerifyAssertions)   VM._assert(VM_Scheduler.getCurrentThread() == this);
  boolean terminateSystem=false;
  if (trace)   VM_Scheduler.trace("String_Node_Str","String_Node_Str");
  if (traceTermination) {
    VM.disableGC();
    VM.sysWriteln("String_Node_Str");
    VM_Scheduler.dumpStack();
    VM.sysWriteln("String_Node_Str");
    VM.enableGC();
  }
  if (VM.BuildForAdaptiveSystem) {
    VM_RuntimeMeasurements.monitorThreadExit();
  }
  java.lang.JikesRVMSupport.threadDied(thread);
  VM_Scheduler.threadCreationMutex.lock("String_Node_Str");
  VM_Processor.getCurrentProcessor().disableThreadSwitching("String_Node_Str");
  hardwareExceptionRegisters.inuse=false;
  VM_Scheduler.numActiveThreads-=1;
  if (daemon) {
    VM_Scheduler.numDaemons-=1;
  }
  if ((VM_Scheduler.numDaemons == VM_Scheduler.numActiveThreads) && (VM.mainThread != null) && VM.mainThread.launched) {
    terminateSystem=true;
  }
  if (traceTermination) {
    VM.sysWriteln("String_Node_Str",daemon);
    VM.sysWriteln("String_Node_Str",VM_Scheduler.numActiveThreads);
    VM.sysWriteln("String_Node_Str",VM_Scheduler.numDaemons);
    VM.sysWriteln("String_Node_Str",terminateSystem);
  }
  VM_Processor.getCurrentProcessor().enableThreadSwitching();
  VM_Scheduler.threadCreationMutex.unlock();
  if (VM.VerifyAssertions) {
    if (VM.fullyBooted || !terminateSystem) {
      VM_Processor.getCurrentProcessor().failIfThreadSwitchingDisabled();
    }
  }
  if (terminateSystem) {
    if (uncaughtExceptionCount > 0) {
      if (VM.TraceExceptionDelivery) {
        VM.sysWriteln("String_Node_Str");
      }
      System.exit(VM.EXIT_STATUS_DYING_WITH_UNCAUGHT_EXCEPTION);
    }
 else     if (thread instanceof VM_MainThread) {
      VM_MainThread mt=(VM_MainThread)thread;
      if (!mt.launched) {
        System.exit(VM.EXIT_STATUS_MAIN_THREAD_COULD_NOT_LAUNCH);
      }
    }
    System.exit(0);
    if (VM.VerifyAssertions)     VM._assert(VM.NOT_REACHED);
  }
  if (jniEnv != null) {
    VM_JNIEnvironment.deallocateEnvironment(jniEnv);
    jniEnv=null;
  }
synchronized (this) {
    state=State.TERMINATED;
    notifyAll(this);
  }
  VM_Scheduler.releaseThreadSlot(threadSlot,this);
  beingDispatched=true;
  VM_Processor.getCurrentProcessor().dispatch(false);
  if (VM.VerifyAssertions)   VM._assert(VM.NOT_REACHED);
}

Fixed version (ground truth):
/** 
 * Terminate execution of current thread by abandoning all references to it and resuming execution in some other (ready) thread.
 */
@Interruptible public final void terminate(){
  if (VM.VerifyAssertions)   VM._assert(VM_Scheduler.getCurrentThread() == this);
  boolean terminateSystem=false;
  if (trace)   VM_Scheduler.trace("String_Node_Str","String_Node_Str");
  if (traceTermination) {
    VM.disableGC();
    VM.sysWriteln("String_Node_Str");
    VM_Scheduler.dumpStack();
    VM.sysWriteln("String_Node_Str");
    VM.enableGC();
  }
  if (VM.BuildForAdaptiveSystem) {
    VM_RuntimeMeasurements.monitorThreadExit();
  }
  java.lang.JikesRVMSupport.threadDied(thread);
  VM_Scheduler.threadCreationMutex.lock("String_Node_Str");
  VM_Processor.getCurrentProcessor().disableThreadSwitching("String_Node_Str");
  hardwareExceptionRegisters.inuse=false;
  VM_Scheduler.numActiveThreads-=1;
  if (daemon) {
    VM_Scheduler.numDaemons-=1;
  }
  if ((VM_Scheduler.numDaemons == VM_Scheduler.numActiveThreads) && (VM.mainThread != null) && VM.mainThread.launched) {
    terminateSystem=true;
  }
  if (terminateSystem) {
    if (systemShuttingDown == false) {
      systemShuttingDown=true;
    }
 else {
      terminateSystem=false;
    }
  }
  if (traceTermination) {
    VM.sysWriteln("String_Node_Str",daemon);
    VM.sysWriteln("String_Node_Str",VM_Scheduler.numActiveThreads);
    VM.sysWriteln("String_Node_Str",VM_Scheduler.numDaemons);
    VM.sysWriteln("String_Node_Str",terminateSystem);
  }
  VM_Processor.getCurrentProcessor().enableThreadSwitching();
  VM_Scheduler.threadCreationMutex.unlock();
  if (VM.VerifyAssertions) {
    if (VM.fullyBooted || !terminateSystem) {
      VM_Processor.getCurrentProcessor().failIfThreadSwitchingDisabled();
    }
  }
  if (terminateSystem) {
    if (uncaughtExceptionCount > 0) {
      if (VM.TraceExceptionDelivery) {
        VM.sysWriteln("String_Node_Str");
      }
      System.exit(VM.EXIT_STATUS_DYING_WITH_UNCAUGHT_EXCEPTION);
    }
 else     if (thread instanceof VM_MainThread) {
      VM_MainThread mt=(VM_MainThread)thread;
      if (!mt.launched) {
        System.exit(VM.EXIT_STATUS_MAIN_THREAD_COULD_NOT_LAUNCH);
      }
    }
    System.exit(0);
    if (VM.VerifyAssertions)     VM._assert(VM.NOT_REACHED);
  }
  if (jniEnv != null) {
    VM_JNIEnvironment.deallocateEnvironment(jniEnv);
    jniEnv=null;
  }
synchronized (this) {
    state=State.TERMINATED;
    notifyAll(this);
  }
  VM_Scheduler.releaseThreadSlot(threadSlot,this);
  beingDispatched=true;
  VM_Processor.getCurrentProcessor().dispatch(false);
  if (VM.VerifyAssertions)   VM._assert(VM.NOT_REACHED);
}