Program: 72597
Project: 72597
Buggy source:
/** 
 * Log a message. Note that arguments after the message are currently ignored.
 * @param modelDescription The model description that containsthe names of the variables.  The FMI specification states that the variable names might not be stored in the C-functions, which is why we can't just use the fmiComponent.
 * @param fmiComponent The component that was instantiated.
 * @param instanceName The name of the instance of the FMU.
 * @param status The fmiStatus, see{@link org.ptolemy.fmi.FMILibrary.FMIStatus}
 * @param category The category of the message,defined by the tool that created the fmu.  Typical values are "log" or "error".
 * @param message The message in printf format
 * @param parameters The printf style parameters.
 */
public static void log(FMIModelDescription modelDescription,Pointer fmiComponent,String instanceName,int status,String category,String message){
  if (_useVariadicExtensions && _pointerClass == null) {
    try {
      _initialize();
    }
 catch (    Throwable throwable) {
      System.out.println("String_Node_Str" + throwable);
      _useVariadicExtensions=false;
    }
  }
  if (!_useVariadicExtensions) {
    FMULog._nonVariadicLog(modelDescription,fmiComponent,instanceName,status,category,message,null);
    return;
  }
  try {
    long ffi_cif=((Long)_nativeCif.invoke(null,new Object[]{fmiComponent})).longValue();
    if (ffi_cif != 0) {
      final char[] msg=message.toCharArray();
      StringBuffer out=new StringBuffer();
      boolean foundEscape=false;
      boolean foundHash=false;
      for (int i=0; i < msg.length; i++) {
        if (foundEscape) {
          final char[] conversions=new char[]{'d','i','o','x','X','e','E','f','F','g','G','a','A','c','s','p','n','u','%'};
          StringBuffer flags=new StringBuffer();
          boolean foundConversion=false;
          boolean foundLong=false;
          while (!foundConversion) {
            if (msg[i] == 'l' || msg[i] == 'L') {
              foundLong=true;
            }
            for (            char c : conversions) {
              if (msg[i] == c) {
                foundConversion=true;
                break;
              }
            }
            if (!foundConversion) {
              flags.append(msg[i]);
              i++;
            }
          }
switch (msg[i]) {
case 'd':
case 'i':
            out.append(String.format("String_Node_Str" + flags.toString() + msg[i],foundLong ? _ffi_closure_va_sint64.invoke(null,new Object[]{ffi_cif}) : _ffi_closure_va_sint32.invoke(null,new Object[]{ffi_cif})));
          break;
case 'o':
case 'x':
case 'X':
case 'u':
        out.append(String.format("String_Node_Str" + flags.toString() + (msg[i] == 'u' ? 'd' : msg[i]),foundLong ? _ffi_closure_va_uint64.invoke(null,new Object[]{ffi_cif}) : _ffi_closure_va_uint32.invoke(null,new Object[]{ffi_cif})));
      break;
case 'e':
case 'E':
case 'f':
case 'F':
case 'g':
case 'G':
case 'a':
case 'A':
    out.append(String.format("String_Node_Str" + flags.toString() + msg[i],_ffi_closure_va_double.invoke(null,new Object[]{ffi_cif})));
  break;
case 'c':
out.append(String.format("String_Node_Str" + flags.toString() + msg[i],(char)_ffi_closure_va_uint8.invoke(null,new Object[]{ffi_cif})));
break;
case 's':
String formatValue="String_Node_Str";
Pointer closureVaPointer=(Pointer)_ffi_closure_va_pointer.invoke(null,new Object[]{ffi_cif});
if (closureVaPointer == null) {
formatValue="String_Node_Str";
}
 else {
formatValue=closureVaPointer.getString(0);
}
out.append(String.format("String_Node_Str" + flags.toString() + "String_Node_Str",formatValue));
break;
case 'p':
out.append(Pointer.nativeValue((Pointer)_ffi_closure_va_pointer.invoke(null,new Object[]{ffi_cif})));
break;
case 'n':
Pointer p=(Pointer)_ffi_closure_va_pointer.invoke(null,new Object[]{ffi_cif});
p.setInt(0,out.length());
break;
case '%':
out.append("String_Node_Str");
break;
default :
System.out.println("String_Node_Str" + msg[i]);
out.append(msg[i]);
break;
}
foundEscape=false;
}
 else if (foundHash) {
if (msg[i] == '#') {
out.append("String_Node_Str");
foundHash=false;
}
 else if (msg[i] == '%') {
foundEscape=true;
}
 else {
out.append(msg[i]);
}
}
 else if (msg[i] == '#') {
out.append("String_Node_Str");
if (msg[i + 1] == '#') {
i++;
}
 else {
foundHash=true;
}
}
 else if (msg[i] == '%') {
foundEscape=true;
}
 else {
out.append(msg[i]);
}
}
System.out.println(FMULogUtilities.fmiStatusToString(status) + "String_Node_Str" + instanceName+ "String_Node_Str"+ category+ "String_Node_Str"+ FMULogUtilities.replaceVariableReferences(modelDescription,out.toString()));
}
}
 catch (Throwable throwable) {
FMULog._nonVariadicLog(modelDescription,fmiComponent,instanceName,status,category,message,null);
}
}

Fixed version (ground truth):
/** 
 * Log a message. Note that arguments after the message are currently ignored.
 * @param modelDescription The model description that containsthe names of the variables.  The FMI specification states that the variable names might not be stored in the C-functions, which is why we can't just use the fmiComponent.
 * @param fmiComponent The component that was instantiated.
 * @param instanceName The name of the instance of the FMU.
 * @param status The fmiStatus, see{@link org.ptolemy.fmi.FMILibrary.FMIStatus}
 * @param category The category of the message,defined by the tool that created the fmu.  Typical values are "log" or "error".
 * @param message The message in printf format
 * @param parameters The printf style parameters.
 */
public static void log(FMIModelDescription modelDescription,Pointer fmiComponent,String instanceName,int status,String category,String message){
  System.out.println("String_Node_Str" + message);
  if (_useVariadicExtensions && _pointerClass == null) {
    try {
      _initialize();
    }
 catch (    Throwable throwable) {
      System.out.println("String_Node_Str" + throwable);
      _useVariadicExtensions=false;
    }
  }
  if (!_useVariadicExtensions) {
    System.out.println("String_Node_Str" + message);
    FMULog._nonVariadicLog(modelDescription,fmiComponent,instanceName,status,category,message,null);
    return;
  }
  System.out.println("String_Node_Str");
  try {
    long ffi_cif=((Long)_nativeCif.invoke(null,new Object[]{fmiComponent})).longValue();
    System.out.println("String_Node_Str" + ffi_cif);
    if (ffi_cif != 0) {
      final char[] msg=message.toCharArray();
      StringBuffer out=new StringBuffer();
      boolean foundEscape=false;
      boolean foundHash=false;
      for (int i=0; i < msg.length; i++) {
        if (foundEscape) {
          final char[] conversions=new char[]{'d','i','o','x','X','e','E','f','F','g','G','a','A','c','s','p','n','u','%'};
          StringBuffer flags=new StringBuffer();
          boolean foundConversion=false;
          boolean foundLong=false;
          while (!foundConversion) {
            if (msg[i] == 'l' || msg[i] == 'L') {
              foundLong=true;
            }
            for (            char c : conversions) {
              if (msg[i] == c) {
                foundConversion=true;
                break;
              }
            }
            if (!foundConversion) {
              flags.append(msg[i]);
              i++;
            }
          }
switch (msg[i]) {
case 'd':
case 'i':
            out.append(String.format("String_Node_Str" + flags.toString() + msg[i],foundLong ? _ffi_closure_va_sint64.invoke(null,new Object[]{ffi_cif}) : _ffi_closure_va_sint32.invoke(null,new Object[]{ffi_cif})));
          break;
case 'o':
case 'x':
case 'X':
case 'u':
        out.append(String.format("String_Node_Str" + flags.toString() + (msg[i] == 'u' ? 'd' : msg[i]),foundLong ? _ffi_closure_va_uint64.invoke(null,new Object[]{ffi_cif}) : _ffi_closure_va_uint32.invoke(null,new Object[]{ffi_cif})));
      break;
case 'e':
case 'E':
case 'f':
case 'F':
case 'g':
case 'G':
case 'a':
case 'A':
    out.append(String.format("String_Node_Str" + flags.toString() + msg[i],_ffi_closure_va_double.invoke(null,new Object[]{ffi_cif})));
  break;
case 'c':
out.append(String.format("String_Node_Str" + flags.toString() + msg[i],_ffi_closure_va_uint8.invoke(null,new Object[]{ffi_cif})));
break;
case 's':
String formatValue="String_Node_Str";
Pointer closureVaPointer=(Pointer)_ffi_closure_va_pointer.invoke(null,new Object[]{ffi_cif});
if (closureVaPointer == null) {
formatValue="String_Node_Str";
}
 else {
formatValue=closureVaPointer.getString(0);
}
out.append(String.format("String_Node_Str" + flags.toString() + "String_Node_Str",formatValue));
break;
case 'p':
out.append(Pointer.nativeValue((Pointer)_ffi_closure_va_pointer.invoke(null,new Object[]{ffi_cif})));
break;
case 'n':
Pointer p=(Pointer)_ffi_closure_va_pointer.invoke(null,new Object[]{ffi_cif});
p.setInt(0,out.length());
break;
case '%':
out.append("String_Node_Str");
break;
default :
System.out.println("String_Node_Str" + msg[i]);
out.append(msg[i]);
break;
}
foundEscape=false;
}
 else if (foundHash) {
if (msg[i] == '#') {
out.append("String_Node_Str");
foundHash=false;
}
 else if (msg[i] == '%') {
foundEscape=true;
}
 else {
out.append(msg[i]);
}
}
 else if (msg[i] == '#') {
out.append("String_Node_Str");
if (msg[i + 1] == '#') {
i++;
}
 else {
foundHash=true;
}
}
 else if (msg[i] == '%') {
foundEscape=true;
}
 else {
out.append(msg[i]);
}
}
System.out.println(FMULogUtilities.fmiStatusToString(status) + "String_Node_Str" + instanceName+ "String_Node_Str"+ category+ "String_Node_Str"+ FMULogUtilities.replaceVariableReferences(modelDescription,out.toString()));
}
}
 catch (Throwable throwable) {
FMULog._nonVariadicLog(modelDescription,fmiComponent,instanceName,status,category,message,null);
}
}