Program: 23381
Project: 23381
Buggy source:
private void generateSnapshot(FetchedFile f,FetchedResource r,StructureDefinition sd,boolean close) throws Exception {
  boolean changed=false;
  dlog("String_Node_Str" + sd.getUrl());
  ProfileUtilities utils=new ProfileUtilities(context,f.getErrors(),igpkp);
  StructureDefinition base=sd.hasBaseDefinition() ? fetchSnapshotted(sd.getBaseDefinition()) : null;
  utils.setIds(sd,true);
  if (sd.getKind() != StructureDefinitionKind.LOGICAL) {
    if (!sd.hasSnapshot()) {
      dlog("String_Node_Str" + sd.getUrl());
      if (base == null)       throw new Exception("String_Node_Str" + sd.getBaseDefinition() + "String_Node_Str"+ sd.getUrl()+ "String_Node_Str");
      List<String> errors=new ArrayList<String>();
      if (close)       utils.closeDifferential(base,sd);
 else       utils.sortDifferential(base,sd,"String_Node_Str" + sd.getUrl(),errors);
      for (      String s : errors)       f.getErrors().add(new ValidationMessage(Source.ProfileValidator,IssueType.INVALID,sd.getUrl(),s,IssueSeverity.ERROR));
      utils.setIds(sd,true);
      String p=sd.getDifferential().getElement().get(0).getPath();
      if (p.contains("String_Node_Str")) {
        changed=true;
        sd.getDifferential().getElement().add(0,new ElementDefinition().setPath(p.substring(0,p.indexOf("String_Node_Str"))));
      }
      utils.generateSnapshot(base,sd,sd.getUrl(),sd.getName());
      changed=true;
    }
  }
 else {
    dlog("String_Node_Str" + sd.getUrl());
    if (!sd.hasSnapshot()) {
      utils.populateLogicalSnapshot(sd);
      changed=true;
    }
  }
  validateExpressions(f,sd);
  if (changed || (!r.getElement().hasChild("String_Node_Str") && sd.hasSnapshot()))   r.setElement(convertToElement(sd));
  r.setSnapshotted(true);
  dlog("String_Node_Str" + sd.getUrl());
  context.seeResource(sd.getUrl(),sd);
}

Fixed version (ground truth):
private void generateSnapshot(FetchedFile f,FetchedResource r,StructureDefinition sd,boolean close) throws Exception {
  boolean changed=false;
  dlog("String_Node_Str" + sd.getUrl());
  ProfileUtilities utils=new ProfileUtilities(context,f.getErrors(),igpkp);
  StructureDefinition base=sd.hasBaseDefinition() ? fetchSnapshotted(sd.getBaseDefinition()) : null;
  utils.setIds(sd,true);
  if (sd.getKind() != StructureDefinitionKind.LOGICAL) {
    if (!sd.hasSnapshot()) {
      dlog("String_Node_Str" + sd.getUrl());
      if (base == null)       throw new Exception("String_Node_Str" + sd.getBaseDefinition() + "String_Node_Str"+ sd.getUrl()+ "String_Node_Str");
      List<String> errors=new ArrayList<String>();
      if (close)       utils.closeDifferential(base,sd);
 else       utils.sortDifferential(base,sd,"String_Node_Str" + sd.getUrl(),errors);
      for (      String s : errors)       f.getErrors().add(new ValidationMessage(Source.ProfileValidator,IssueType.INVALID,sd.getUrl(),s,IssueSeverity.ERROR));
      utils.setIds(sd,true);
      String p=sd.getDifferential().getElement().get(0).getPath();
      if (p.contains("String_Node_Str")) {
        changed=true;
        sd.getDifferential().getElement().add(0,new ElementDefinition().setPath(p.substring(0,p.indexOf("String_Node_Str"))));
      }
      utils.generateSnapshot(base,sd,sd.getUrl(),sd.getName());
      changed=true;
    }
  }
 else {
    dlog("String_Node_Str" + sd.getUrl());
    if (!sd.hasSnapshot()) {
      utils.populateLogicalSnapshot(sd);
      changed=true;
    }
  }
  if (changed || (!r.getElement().hasChild("String_Node_Str") && sd.hasSnapshot()))   r.setElement(convertToElement(sd));
  r.setSnapshotted(true);
  dlog("String_Node_Str" + sd.getUrl());
  context.seeResource(sd.getUrl(),sd);
}