Program: 46527
Project: 46527
Buggy source:
@Override public void run(){
  EncryptionKey vmKey=null;
  EncryptionKey rtKey=null;
  try {
    Chronos c=new Chronos();
    c.zap("String_Node_Str");
    ctrl.setTempStatus(vm,VmState.STARTING);
    vm.setProgressMessage(I18nBundleProvider.getBundle().getString("String_Node_Str"));
    ctrl.refreshVmState(vm);
    c.zap("String_Node_Str");
    vmKey=keyring.getKey(vm.getVmContainer().getId());
    c.zap("String_Node_Str");
    rtKey=keyring.getKey(vm.getRuntimeContainer().getId());
    c.zap("String_Node_Str");
    containerFactory.mountContainer(vm.getVmContainer(),vmKey);
    c.zap("String_Node_Str");
    containerFactory.mountContainer(vm.getRuntimeContainer(),rtKey);
    c.zap("String_Node_Str");
    rtKey.shred();
    c.zap("String_Node_Str");
    vmKey.shred();
    c.zap("String_Node_Str");
    File sessionTransferFolder=new File(transfer.getMountpoint(),vm.getId() + "String_Node_Str");
    vm.setTempFolder(new File(sessionTransferFolder,"String_Node_Str"));
    vm.setImportFolder(new File(sessionTransferFolder,"String_Node_Str"));
    vm.setExportFolder(new File(sessionTransferFolder,"String_Node_Str"));
    vm.getTempFolder().mkdirs();
    vm.getImportFolder().mkdirs();
    vm.getExportFolder().mkdirs();
    c.zap("String_Node_Str");
    product.registerVm(vm);
    c.zap("String_Node_Str");
    vpnManager.openVpn(vm,keyring,new VpnListener(){
      @Override public void opened(){
        try {
          while (product.getProductState(vm) == VmProductState.STARTING) {
            Thread.sleep(500);
          }
          product.connectNic(vm,true);
        }
 catch (        Exception e) {
          LOG.error("String_Node_Str",e);
          vm.setVpnState(VmVpnState.NOT_CONNECTED);
          vmModel.fireVmStateUpdatedEvent(vm);
        }
        vm.setVpnState(VmVpnState.CONNECTED);
        vmModel.fireVmStateUpdatedEvent(vm);
      }
      @Override public void closed(){
        try {
          product.connectNic(vm,false);
        }
 catch (        VmException e) {
          LOG.error("String_Node_Str",e);
        }
        vm.setVpnState(VmVpnState.NOT_CONNECTED);
        vmModel.fireVmStateUpdatedEvent(vm);
      }
      @Override public void connecting(){
        try {
          product.connectNic(vm,false);
          vm.setVpnState(VmVpnState.CONNECTING);
        }
 catch (        VmException e) {
          LOG.error("String_Node_Str",e);
          vm.setVpnState(VmVpnState.NOT_CONNECTED);
        }
        vmModel.fireVmStateUpdatedEvent(vm);
      }
      @Override public void failed(){
        try {
          product.connectNic(vm,false);
        }
 catch (        VmException e) {
          LOG.error("String_Node_Str",e);
        }
        vm.setVpnState(VmVpnState.NOT_CONNECTED);
        vmModel.fireVmStateUpdatedEvent(vm);
      }
    }
);
    c.zap("String_Node_Str");
    product.startVm(vm);
    c.zap("String_Node_Str");
    boolean isUnknown=false;
    long isUnknownSince=0;
    long timeout=System.currentTimeMillis() + START_TIMEOUT;
    while (System.currentTimeMillis() < timeout) {
      VmProductState ps=product.getProductState(vm);
      if (ps == VmProductState.RUNNING || ps == VmProductState.ERROR) {
        c.zap("String_Node_Str" + ps + "String_Node_Str");
        break;
      }
 else       if (ps == VmProductState.UNKNOWN) {
        if (isUnknown) {
          if (isUnknownSince + UNKNOWN_STATE_TIMEOUT < System.currentTimeMillis()) {
            LOG.debug("String_Node_Str");
            break;
          }
        }
 else {
          isUnknown=true;
          isUnknownSince=System.currentTimeMillis();
          LOG.debug("String_Node_Str");
        }
      }
 else {
        isUnknown=false;
      }
      LOG.debug("String_Node_Str");
      Thread.sleep(500);
    }
    c.zap("String_Node_Str" + product.getProductState(vm) + "String_Node_Str");
    LOG.debug("String_Node_Str",product.getProductState(vm));
  }
 catch (  Exception e) {
    LOG.error("String_Node_Str",e);
  }
 finally {
    if (rtKey != null)     rtKey.shred();
    if (vmKey != null)     vmKey.shred();
    ctrl.clearTempStatus(vm);
    ctrl.refreshVmState(vm);
  }
}

Fixed version (ground truth):
@Override public void run(){
  EncryptionKey vmKey=null;
  EncryptionKey rtKey=null;
  try {
    Chronos c=new Chronos();
    c.zap("String_Node_Str");
    ctrl.setTempStatus(vm,VmState.STARTING);
    vm.setProgressMessage(I18nBundleProvider.getBundle().getString("String_Node_Str"));
    ctrl.refreshVmState(vm);
    c.zap("String_Node_Str");
    vmKey=keyring.getKey(vm.getVmContainer().getId());
    c.zap("String_Node_Str");
    rtKey=keyring.getKey(vm.getRuntimeContainer().getId());
    c.zap("String_Node_Str");
    containerFactory.mountContainer(vm.getVmContainer(),vmKey);
    c.zap("String_Node_Str");
    containerFactory.mountContainer(vm.getRuntimeContainer(),rtKey);
    c.zap("String_Node_Str");
    rtKey.shred();
    c.zap("String_Node_Str");
    vmKey.shred();
    c.zap("String_Node_Str");
    File sessionTransferFolder=new File(transfer.getMountpoint(),vm.getId() + "String_Node_Str");
    vm.setTempFolder(new File(sessionTransferFolder,"String_Node_Str"));
    vm.setImportFolder(new File(sessionTransferFolder,"String_Node_Str"));
    vm.setExportFolder(new File(sessionTransferFolder,"String_Node_Str"));
    vm.getTempFolder().mkdirs();
    vm.getImportFolder().mkdirs();
    vm.getExportFolder().mkdirs();
    c.zap("String_Node_Str");
    product.registerVm(vm);
    c.zap("String_Node_Str");
    vpnManager.openVpn(vm,keyring,new VpnListener(){
      @Override public void opened(){
        try {
          while (product.getProductState(vm) == VmProductState.STARTING) {
            Thread.sleep(500);
          }
          product.connectNic(vm,true);
          vm.setVpnState(VmVpnState.CONNECTED);
        }
 catch (        Exception e) {
          LOG.error("String_Node_Str",e);
          vm.setVpnState(VmVpnState.NOT_CONNECTED);
        }
        vmModel.fireVmStateUpdatedEvent(vm);
      }
      @Override public void closed(){
        try {
          product.connectNic(vm,false);
        }
 catch (        VmException e) {
          LOG.error("String_Node_Str",e);
        }
        vm.setVpnState(VmVpnState.NOT_CONNECTED);
        vmModel.fireVmStateUpdatedEvent(vm);
      }
      @Override public void connecting(){
        try {
          product.connectNic(vm,false);
          vm.setVpnState(VmVpnState.CONNECTING);
        }
 catch (        VmException e) {
          LOG.error("String_Node_Str",e);
          vm.setVpnState(VmVpnState.NOT_CONNECTED);
        }
        vmModel.fireVmStateUpdatedEvent(vm);
      }
      @Override public void failed(){
        try {
          product.connectNic(vm,false);
        }
 catch (        VmException e) {
          LOG.error("String_Node_Str",e);
        }
        vm.setVpnState(VmVpnState.NOT_CONNECTED);
        vmModel.fireVmStateUpdatedEvent(vm);
      }
    }
);
    c.zap("String_Node_Str");
    product.startVm(vm);
    c.zap("String_Node_Str");
    boolean isUnknown=false;
    long isUnknownSince=0;
    long timeout=System.currentTimeMillis() + START_TIMEOUT;
    while (System.currentTimeMillis() < timeout) {
      VmProductState ps=product.getProductState(vm);
      if (ps == VmProductState.RUNNING || ps == VmProductState.ERROR) {
        c.zap("String_Node_Str" + ps + "String_Node_Str");
        break;
      }
 else       if (ps == VmProductState.UNKNOWN) {
        if (isUnknown) {
          if (isUnknownSince + UNKNOWN_STATE_TIMEOUT < System.currentTimeMillis()) {
            LOG.debug("String_Node_Str");
            break;
          }
        }
 else {
          isUnknown=true;
          isUnknownSince=System.currentTimeMillis();
          LOG.debug("String_Node_Str");
        }
      }
 else {
        isUnknown=false;
      }
      LOG.debug("String_Node_Str");
      Thread.sleep(500);
    }
    c.zap("String_Node_Str" + product.getProductState(vm) + "String_Node_Str");
    LOG.debug("String_Node_Str",product.getProductState(vm));
  }
 catch (  Exception e) {
    LOG.error("String_Node_Str",e);
  }
 finally {
    if (rtKey != null)     rtKey.shred();
    if (vmKey != null)     vmKey.shred();
    ctrl.clearTempStatus(vm);
    ctrl.refreshVmState(vm);
  }
}