Program: 75632
Project: 75632
Buggy source:
/** 
 * Create shadow variables for the port, if it is an input port, and otherwise do nothing. The shadow variables are contained by this actor and can be referenced in the guard and trigger expressions of transitions.  The shadow variables are lazy so that they are not evaluated until their values are needed, so the guard and trigger transitions should also be lazy. <p> If the given port is not a multiport, but is connected to something, then two variables are created: one is input status variable with name "<i>portName</i>_isPresent"; the other is input value variable with name "<i>portName</i>". The input status variable always contains a BooleanToken. When this actor is fired, the status variable is set to <i>true</i> if the port has a token, and to <i>false</i> otherwise. The input value variable always contains the latest token received from the port. <p> If the given port is a multiport, a status variable and a value variable are created for each channel. The status variable is named "<i>portName</i>_<i>channelIndex</i>_isPresent". The value variable is named "<i>portName</i>_<i>channelIndex</i>". <p> If a variable to be created has the same name as an attribute already contained by this actor, that attribute will be removed from this actor by setting its container to null.
 * @param port The port for which to create a shadow variable.
 * @exception IllegalActionException If the port is not containedby this FSMActor.
 */
protected void _createInputVariables(IOPort port) throws IllegalActionException {
  if (port.getContainer() != this) {
    throw new IllegalActionException(this,port,"String_Node_Str" + "String_Node_Str");
  }
  if (!port.isInput()) {
    return;
  }
  if (_inputVariableMap.get(port) != null) {
    _removeInputVariables(port);
  }
  int width=port.getWidth();
  if (width == 0) {
    return;
  }
  Variable[][] shadowVariables=new Variable[width][2];
  String portName=port.getName();
  for (int channelIndex=0; channelIndex < width; ++channelIndex) {
    if (_stopRequested)     break;
    String shadowName=null;
    if (port.isMultiport()) {
      shadowName=portName + "String_Node_Str" + channelIndex;
    }
 else {
      shadowName=portName;
    }
    String predicateName=shadowName + "String_Node_Str";
    Attribute previousAttribute=getAttribute(predicateName);
    try {
      if (previousAttribute != null) {
        previousAttribute.setContainer(null);
      }
      shadowVariables[channelIndex][0]=new Variable(this,predicateName);
      shadowVariables[channelIndex][0].setLazy(true);
    }
 catch (    NameDuplicationException ex) {
      throw new InternalErrorException(getName() + "String_Node_Str" + "String_Node_Str"+ portName+ "String_Node_Str"+ ex.getMessage());
    }
    previousAttribute=getAttribute(shadowName);
    try {
      if (previousAttribute != null) {
        previousAttribute.setContainer(null);
      }
      shadowVariables[channelIndex][1]=new Variable(this,shadowName);
      shadowVariables[channelIndex][1].setLazy(true);
    }
 catch (    NameDuplicationException ex) {
      throw new InvalidStateException(this,"String_Node_Str" + ex.getMessage());
    }
  }
  _inputVariableMap.put(port,shadowVariables);
}

Fixed version (ground truth):
/** 
 * Create shadow variables for the port, if it is an input port, and otherwise do nothing. The shadow variables are contained by this actor and can be referenced in the guard and trigger expressions of transitions.  The shadow variables are lazy so that they are not evaluated until their values are needed, so the guard and trigger transitions should also be lazy. <p> If the given port is not a multiport, but is connected to something, then two variables are created: one is input status variable with name "<i>portName</i>_isPresent"; the other is input value variable with name "<i>portName</i>". The input status variable always contains a BooleanToken. When this actor is fired, the status variable is set to <i>true</i> if the port has a token, and to <i>false</i> otherwise. The input value variable always contains the latest token received from the port. <p> If the given port is a multiport, a status variable and a value variable are created for each channel. The status variable is named "<i>portName</i>_<i>channelIndex</i>_isPresent". The value variable is named "<i>portName</i>_<i>channelIndex</i>". <p> If a variable to be created has the same name as an attribute already contained by this actor, that attribute will be removed from this actor by setting its container to null.
 * @param port The port for which to create a shadow variable.
 * @exception IllegalActionException If the port is not containedby this FSMActor.
 */
protected void _createInputVariables(IOPort port) throws IllegalActionException {
  if (port.getContainer() != this) {
    throw new IllegalActionException(this,port,"String_Node_Str" + "String_Node_Str");
  }
  if (!port.isInput()) {
    return;
  }
  if (_inputVariableMap.get(port) != null) {
    _removeInputVariables(port);
  }
  int width=port.getWidth();
  if (width == 0) {
    return;
  }
  Variable[][] shadowVariables=new Variable[width][2];
  String portName=port.getName();
  for (int channelIndex=0; channelIndex < width; ++channelIndex) {
    String shadowName=null;
    if (port.isMultiport()) {
      shadowName=portName + "String_Node_Str" + channelIndex;
    }
 else {
      shadowName=portName;
    }
    String predicateName=shadowName + "String_Node_Str";
    Attribute previousAttribute=getAttribute(predicateName);
    try {
      if (previousAttribute != null) {
        previousAttribute.setContainer(null);
      }
      shadowVariables[channelIndex][0]=new Variable(this,predicateName);
      shadowVariables[channelIndex][0].setLazy(true);
    }
 catch (    NameDuplicationException ex) {
      throw new InternalErrorException(getName() + "String_Node_Str" + "String_Node_Str"+ portName+ "String_Node_Str"+ ex.getMessage());
    }
    previousAttribute=getAttribute(shadowName);
    try {
      if (previousAttribute != null) {
        previousAttribute.setContainer(null);
      }
      shadowVariables[channelIndex][1]=new Variable(this,shadowName);
      shadowVariables[channelIndex][1].setLazy(true);
    }
 catch (    NameDuplicationException ex) {
      throw new InvalidStateException(this,"String_Node_Str" + ex.getMessage());
    }
  }
  _inputVariableMap.put(port,shadowVariables);
}