The attached saved game consistently throws an exception while "Waiting for Sioux":
AWT-EventQueue-0[1] java.lang.NullPointerException
at net.sf.freecol.client.gui.ImageLibrary.getUnitImageIcon(ImageLibrary.java:1166)
at net.sf.freecol.client.gui.ImageLibrary.getUnitImageIcon(ImageLibrary.java:1207)
at net.sf.freecol.client.gui.ImageLibrary.getUnitImageIcon(ImageLibrary.java:1178)
at net.sf.freecol.client.gui.GUI.displayUnit(GUI.java:2777)
at net.sf.freecol.client.gui.GUI.displayMap(GUI.java:1338)
at net.sf.freecol.client.gui.GUI.display(GUI.java:951)
at net.sf.freecol.client.gui.Canvas.paintComponent(Canvas.java:376)
This is running 0.9.x at revision 7031.
Digging a bit further, jdb tells me unitType is null at line 1166, but I don't see how it can be - there is a check for null at line 1337 of displayMap.
Memory corruption or a threading problem? Any suggestions on what to look at next?
Minimal steps to reproduce the exception:
load game
end turn
close turn report
move NW scout to Phah Sapa and ask to speak with the chief
end turn
next sioux turn hits the exception
I tracked this down to a brave unit that somehow ends up with a null UnitType and a null Owner. Earlier in the log the same unit has a non-null UnitType and Owner.
net.sf.freecol.common.model.SimpleCombatModel getDefensiveModifiers
WARNING: getDefensiveModifiers: unit:16481 (model.unit.brave/DEFAULT) 1/1 ServerPlayer[name=Taoyateduta,serverID=player:29,conn=DummyConnection[Server-Server-Taoyateduta]]
Sat Jun 26 22:32:23 MDT 2010
Thread ID: 132
...
net.sf.freecol.client.control.InGameInputHandler$UnitMoveAnimationCanvasSwingTask doWork
WARNING: Unit unit:16481 has no owner
Sat Jun 26 22:32:23 MDT 2010
Thread ID: 11
net.sf.freecol.client.control.InGameInputHandler$SwingTask run
FINEST: Swing task net.sf.freecol.client.control.InGameInputHandler$UnitMoveAnimationCanvasSwingTask returned null
Sat Jun 26 22:32:23 MDT 2010
Thread ID: 11
net.sf.freecol.common.networking.Connection$1 run
WARNING: Message handler failed!
Sat Jun 26 22:32:23 MDT 2010
Thread ID: 135
Stack trace:
java.lang.IllegalStateException: Unit unit:16481 has no owner
at net.sf.freecol.common.model.Unit.contactAdjacent(Unit.java:2073)
at net.sf.freecol.common.model.Unit.setLocation(Unit.java:2055)
at net.sf.freecol.client.control.InGameInputHandler.opponentMove(InGameInputHandler.java:313)
at net.sf.freecol.client.control.InGameInputHandler.handle(InGameInputHandler.java:117)
at net.sf.freecol.common.networking.Connection$1.run(Connection.java:507)
Looks nasty. Alas, I could not load the attached save game with either current trunk or svn.7031.
This patch works around the exception by ignoring the offending unit:
Index: src/net/sf/freecol/client/control/InGameInputHandler.java
--- src/net/sf/freecol/client/control/InGameInputHandler.java (revision 7058)
+++ src/net/sf/freecol/client/control/InGameInputHandler.java (working copy)
@@ -303,7 +303,15 @@
new RefreshTilesSwingTask(unit.getTile(), toTile).invokeLater();
}
if (getFreeColClient().getMyPlayer().canSee(toTile)) {
- unit.setLocation(toTile);
+ if (unit.getOwner() == null) {
+ logger.warning("unit " + unit.getId() + " has null owner");
+ }
+ else if (unit.getType() == null) {
+ logger.warning("unit " + unit.getId() + " has null type");
+ }
+ else {
+ unit.setLocation(toTile);
+ }
} else {
unit.dispose();
}
Oh sorry, I misreported the revision:
$ svn info
Path: .
URL: https://freecol.svn.sourceforge.net/svnroot/freecol/freecol/branches/0.9.x
Repository Root: https://freecol.svn.sourceforge.net/svnroot/freecol
Repository UUID: 04c0ca24-bb37-0410-963f-fb4f4e597ea7
Revision: 7058
Node Kind: directory
Schedule: normal
Last Changed Author: burschik
Last Changed Rev: 7056
Last Changed Date: 2010-06-23 00:03:14 -0600 (Wed, 23 Jun 2010)
Alas, no improvement with 7058. The unit without an owner is indicative of some nasty corruption, and it looks to me as if it is in the save game. Do you perhaps have a save game from a move or moves before the attached one?
Yes, I do. However, I don't see a way to add a file to this bug report. What am I missing?
You need to log in. The "Add a File" box does not appear for guest/nobody.
According to sf support:
"As a spam prevention measure, only project administrators and the
bug submitter are able to add files to Tracker tickets."
I logged in but still couldn't add any files. I can provide them via email if that helps.
This artifact has been marked as a duplicate of artifact 3041198 with reason:
Same bug. prefer later