triplea icon indicating copy to clipboard operation
triplea copied to clipboard

2.5.22294: ProSortMoveOptionsUtils#sortUnitNeededOptionsThenAttack:117 - java.lang.IllegalArgumentException

Open tripleabuilderbot opened this issue 4 years ago • 11 comments

Map

a_song_of_ice_and_fire

Log Message

Comparison method violates its general contract!

TripleA Version

2.5.22294

Java Version

11.0.6

Operating System

Windows 10

Memory

Heap utilization statistics [MB] Used Memory: 430 Free memory: 1548 Total memory: 1979 Max memory: 1979

Stack Trace

Exception: java.lang.IllegalArgumentExceptionComparison method violates its general contract!
java.lang.Exception
	at java.base/java.util.TimSort.mergeHi(TimSort.java:903)
	at java.base/java.util.TimSort.mergeAt(TimSort.java:520)
	at java.base/java.util.TimSort.mergeCollapse(TimSort.java:448)
	at java.base/java.util.TimSort.sort(TimSort.java:245)
	at java.base/java.util.Arrays.sort(Arrays.java:1515)
	at java.base/java.util.ArrayList.sort(ArrayList.java:1749)
	at games.strategy.triplea.ai.pro.util.ProSortMoveOptionsUtils.sortUnitNeededOptionsThenAttack(ProSortMoveOptionsUtils.java:117)
	at games.strategy.triplea.ai.pro.ProCombatMoveAi.tryToAttackTerritories(ProCombatMoveAi.java:1410)
	at games.strategy.triplea.ai.pro.ProCombatMoveAi.determineTerritoriesToAttack(ProCombatMoveAi.java:335)
	at games.strategy.triplea.ai.pro.ProCombatMoveAi.doCombatMove(ProCombatMoveAi.java:95)
	at games.strategy.triplea.ai.pro.AbstractProAi.move(AbstractProAi.java:139)
	at games.strategy.triplea.ai.AbstractAi.start(AbstractAi.java:514)
	at games.strategy.engine.framework.ServerGame.waitForPlayerToFinishStep(ServerGame.java:537)
	at games.strategy.engine.framework.ServerGame.runStep(ServerGame.java:407)
	at games.strategy.engine.framework.ServerGame.startGame(ServerGame.java:297)
	at games.strategy.engine.framework.startup.launcher.LocalLauncher.launchInternal(LocalLauncher.java:82)
	at games.strategy.engine.framework.startup.launcher.LocalLauncher.lambda$launch$0(LocalLauncher.java:56)
	at java.base/java.lang.Thread.run(Thread.java:834)


tripleabuilderbot avatar Nov 02 '20 21:11 tripleabuilderbot

This just happened to me too while letting the game playing with every player assigned to Hard AI. 2973.8 MB of RAM is assigned to the process immediately or shortly after it crashed.

Cernelius avatar Mar 08 '21 02:03 Cernelius

INFORMAZIONI: Exception while launching
java.lang.IllegalArgumentException: Comparison method violates its general contract!
	at java.base/java.util.TimSort.mergeHi(TimSort.java:903)
	at java.base/java.util.TimSort.mergeAt(TimSort.java:520)
	at java.base/java.util.TimSort.mergeForceCollapse(TimSort.java:461)
	at java.base/java.util.TimSort.sort(TimSort.java:254)
	at java.base/java.util.Arrays.sort(Arrays.java:1515)
	at java.base/java.util.ArrayList.sort(ArrayList.java:1749)
	at games.strategy.triplea.ai.pro.util.ProSortMoveOptionsUtils.sortUnitNeededOptionsThenAttack(ProSortMoveOptionsUtils.java:117)
	at games.strategy.triplea.ai.pro.ProCombatMoveAi.tryToAttackTerritories(ProCombatMoveAi.java:1304)
	at games.strategy.triplea.ai.pro.ProCombatMoveAi.determineUnitsToAttackWith(ProCombatMoveAi.java:867)
	at games.strategy.triplea.ai.pro.ProCombatMoveAi.doCombatMove(ProCombatMoveAi.java:116)
	at games.strategy.triplea.ai.pro.AbstractProAi.move(AbstractProAi.java:139)
	at games.strategy.triplea.ai.AbstractAi.start(AbstractAi.java:514)
	at games.strategy.engine.framework.ServerGame.waitForPlayerToFinishStep(ServerGame.java:537)
	at games.strategy.engine.framework.ServerGame.runStep(ServerGame.java:407)
	at games.strategy.engine.framework.ServerGame.startGame(ServerGame.java:297)
	at games.strategy.engine.framework.startup.launcher.ServerLauncher.launchInternal(ServerLauncher.java:173)
	at java.base/java.lang.Thread.run(Thread.java:834)

mar 08, 2021 3:36:12 AM games.strategy.engine.framework.startup.launcher.ServerLauncher launchInternal
GRAVE: Unrecognized error occurred. If this is a repeatable error, please make a copy of this savegame and report to:
https://github.com/triplea-game/triplea/issues/new
java.lang.IllegalArgumentException: Comparison method violates its general contract!
	at java.base/java.util.TimSort.mergeHi(TimSort.java:903)
	at java.base/java.util.TimSort.mergeAt(TimSort.java:520)
	at java.base/java.util.TimSort.mergeForceCollapse(TimSort.java:461)
	at java.base/java.util.TimSort.sort(TimSort.java:254)
	at java.base/java.util.Arrays.sort(Arrays.java:1515)
	at java.base/java.util.ArrayList.sort(ArrayList.java:1749)
	at games.strategy.triplea.ai.pro.util.ProSortMoveOptionsUtils.sortUnitNeededOptionsThenAttack(ProSortMoveOptionsUtils.java:117)
	at games.strategy.triplea.ai.pro.ProCombatMoveAi.tryToAttackTerritories(ProCombatMoveAi.java:1304)
	at games.strategy.triplea.ai.pro.ProCombatMoveAi.determineUnitsToAttackWith(ProCombatMoveAi.java:867)
	at games.strategy.triplea.ai.pro.ProCombatMoveAi.doCombatMove(ProCombatMoveAi.java:116)
	at games.strategy.triplea.ai.pro.AbstractProAi.move(AbstractProAi.java:139)
	at games.strategy.triplea.ai.AbstractAi.start(AbstractAi.java:514)
	at games.strategy.engine.framework.ServerGame.waitForPlayerToFinishStep(ServerGame.java:537)
	at games.strategy.engine.framework.ServerGame.runStep(ServerGame.java:407)
	at games.strategy.engine.framework.ServerGame.startGame(ServerGame.java:297)
	at games.strategy.engine.framework.startup.launcher.ServerLauncher.launchInternal(ServerLauncher.java:173)
	at java.base/java.lang.Thread.run(Thread.java:834)

Cernelius avatar Mar 08 '21 02:03 Cernelius

Having a save file where this happens consistently would be very valuable. The sort code in question is incredibly complex, it's not clear in what conditions it fails the transitive property. (IE, the underlying sort library will throw this error if it sees, "a < b", and "b < c", but "a > c").

If we can figure out which situation this happens in, it'll give us a much more solid basis. I am aware of this having been an error for some time, I don't think it's new (but perhaps is more prevalent with some of the newer maps, which suggest that some of the less used unit attributes are contributing factors here).

DanVanAtta avatar Mar 08 '21 04:03 DanVanAtta

@DanVanAtta Here's a save file example:

2021-3-15-Twelve-Clans.zip

vbnet3d avatar Mar 15 '21 17:03 vbnet3d

Triggers on following AI's turn. GJ.zip

Iron-Knight avatar May 12 '21 17:05 Iron-Knight

I checked the two save files and they don't repro on current tip of tree (2.6). But it's possible the AI just does different decisions and doesn't trigger the bug.

asvitkine avatar Feb 25 '22 02:02 asvitkine

I surmise you can reproduce it by starting a new game with every player assigned to Hard AI and let it run until it crashes. I suppose you can do something else meanwhile.

Cernelius avatar Feb 25 '22 05:02 Cernelius

I surmise you can reproduce it by starting a new game with every player assigned to Hard AI and let it run until it crashes. I suppose you can do something else meanwhile.

I tried with the Twelve Clans map and after 25 rounds, the error hasn't happened. I could try with another map, but I suspect either this problem is fixed, or it requires some decision that requires a human player (e.g. purchasing a unit that the AI never purchases).

asvitkine avatar Feb 25 '22 23:02 asvitkine

I recall I hit it twice on this game with the current release and I believe I've never hit it in any other game. I'm not really interested in this problem as I virtually never play with the AI, so I'm not a good reference on the matter.

If the problem doesn't occur with the prerelease, I would close this issue.

Cernelius avatar Feb 26 '22 00:02 Cernelius

Both times I was not playing with the AI: I was letting the game running with all players assigned to Hard AI. I had a mild interest on how the AI would handle such a complex map.

Cernelius avatar Feb 26 '22 00:02 Cernelius

@DanVanAtta unsure to close. is there a label I can add so I don't spam you out ? 5 outta 70 so far. Probably be more the closer to the finish line though

beelee1 avatar Oct 28 '22 03:10 beelee1