Program: 45641
Project: 45641
Buggy source:
/** 
 * Change the current avatar to the given avatar. NOTE: This method must be called in the MT Game Render Thread. As such, we assume only one of these methods is called at a time.
 * @param newAvatar The new avatar to change to.
 */
private void changeAvatarInternal(WlAvatarCharacter newAvatar){
  if (newAvatar == null)   return;
  LoadingInfo.startedLoading(cell.getCellID(),newAvatar.getName());
  Node nameTagNode=getNameTagNode();
  PMatrix currentLocation=null;
  boolean wasSelectedForInput=false;
  if (avatarCharacter != null) {
    currentLocation=avatarCharacter.getModelInst().getTransform().getWorldMatrix(true);
    rootEntity.removeEntity(avatarCharacter);
    avatarCharacter.getJScene().getExternalKidsRoot().detachChild(nameTagNode);
    wasSelectedForInput=selectedForInput;
    selectForInput(false);
    avatarCharacter.destroy();
  }
  avatarCharacter=newAvatar;
  if (newAvatar == null) {
    return;
  }
  RenderComponent rc=(RenderComponent)avatarCharacter.getComponent(RenderComponent.class);
  addDefaultComponents(avatarCharacter,rc.getSceneRoot());
  avatarCharacter.removeComponent(CollisionComponent.class);
  if (currentLocation != null && avatarCharacter.getModelInst() != null) {
    avatarCharacter.getModelInst().setTransform(new PTransform(currentLocation));
  }
  Node externalRoot=avatarCharacter.getJScene().getExternalKidsRoot();
  externalRoot.attachChild(nameTagNode);
  externalRoot.setModelBound(new BoundingSphere());
  externalRoot.updateModelBound();
  externalRoot.updateGeometricState(0,true);
  rootEntity.addEntity(avatarCharacter);
  if (cell instanceof AvatarCell) {
    selectForInput(((AvatarCell)cell).isSelectedForInput());
  }
  for (  WeakReference<AvatarChangedListener> listenerRef : avatarChangedListeners) {
    AvatarChangedListener listener=listenerRef.get();
    if (listener != null) {
      listener.avatarChanged(avatarCharacter);
    }
 else {
      avatarChangedListeners.remove(listenerRef);
    }
  }
  if (avatarCharacter.getJScene() != null) {
    avatarCharacter.getPScene().submitTransformsAndGeometry(true);
    avatarCharacter.getJScene().setModelBound(new BoundingSphere());
    avatarCharacter.getJScene().updateModelBound();
    avatarCharacter.getJScene().updateWorldBound();
  }
  LoadingInfo.finishedLoading(cell.getCellID(),newAvatar.getName());
}

Fixed version (ground truth):
/** 
 * Change the current avatar to the given avatar. NOTE: This method must be called in the MT Game Render Thread. As such, we assume only one of these methods is called at a time.
 * @param newAvatar The new avatar to change to.
 */
private void changeAvatarInternal(WlAvatarCharacter newAvatar){
  if (newAvatar == null)   return;
  LoadingInfo.startedLoading(cell.getCellID(),newAvatar.getName());
  Node nameTagNode=getNameTagNode();
  PMatrix currentLocation=null;
  if (avatarCharacter != null) {
    currentLocation=avatarCharacter.getModelInst().getTransform().getWorldMatrix(true);
    rootEntity.removeEntity(avatarCharacter);
    avatarCharacter.getJScene().getExternalKidsRoot().detachChild(nameTagNode);
    selectForInput(false);
    avatarCharacter.destroy();
  }
  avatarCharacter=newAvatar;
  if (newAvatar == null) {
    return;
  }
  RenderComponent rc=(RenderComponent)avatarCharacter.getComponent(RenderComponent.class);
  addDefaultComponents(avatarCharacter,rc.getSceneRoot());
  avatarCharacter.removeComponent(CollisionComponent.class);
  if (currentLocation != null && avatarCharacter.getModelInst() != null) {
    avatarCharacter.getModelInst().setTransform(new PTransform(currentLocation));
  }
  Node externalRoot=avatarCharacter.getJScene().getExternalKidsRoot();
  if (nameTagNode != null) {
    externalRoot.attachChild(nameTagNode);
    externalRoot.setModelBound(new BoundingSphere());
    externalRoot.updateModelBound();
    externalRoot.updateGeometricState(0,true);
  }
  rootEntity.addEntity(avatarCharacter);
  if (cell instanceof AvatarCell) {
    selectForInput(((AvatarCell)cell).isSelectedForInput());
  }
  for (  WeakReference<AvatarChangedListener> listenerRef : avatarChangedListeners) {
    AvatarChangedListener listener=listenerRef.get();
    if (listener != null) {
      listener.avatarChanged(avatarCharacter);
    }
 else {
      avatarChangedListeners.remove(listenerRef);
    }
  }
  if (avatarCharacter.getJScene() != null) {
    avatarCharacter.getPScene().submitTransformsAndGeometry(true);
    avatarCharacter.getJScene().setModelBound(new BoundingSphere());
    avatarCharacter.getJScene().updateModelBound();
    avatarCharacter.getJScene().updateWorldBound();
  }
  LoadingInfo.finishedLoading(cell.getCellID(),newAvatar.getName());
}