Replicable resource/memory issue when loading/closing games

Computer: various (my own, and people who send me bug reports)
VASSAL: 3.2.12
Java: version 7 update 55 (in my case)
Module: Mage Knight Board Game: The Lost Legion & Krang v151 (not on the Vassal site, probably not important for the bug report, but available from dropbox.com/s/aqh0ngtf3s70t … _v151.vmod)
Sample logs:
dropbox.com/s/xp0qnmp4q5sudld/2-round1.vlog
dropbox.com/s/hyl35xoi6i3a0r2/2-round2.vlog
dropbox.com/s/zxq33u55kyi01ac/2-round3.vlog
dropbox.com/s/k8uhrajefodx7ci/2-round4.vlog
dropbox.com/s/2wf279gewen7pej/2-round5.vlog
dropbox.com/s/2iks0f8nz679d … nd5-2.vlog

In brief:
An action button pressed after loading and viewing a log (for example, log4) produces different results (intended or buggy) depending on whether the log is loaded immediately after starting the module or is loaded after selecting load game (log1) > close game > load game (log2) > close game > load game (log3) > close game > load game (log4).

In detail:
The above module contains a fairly complex round-end procedure that does a lot of book-keeping with triggers that activate global key commands followed by a global hotkey shuffle. If a player has the module open for a few rounds, loading and closing a series of logs, the 4th or 5th time (for example) the round-end procedure is triggered, the global hotkey that triggers shuffling goes off anywhere between 2 and 8 times per deck according to the reporting (should be once), and decks disappear or appear face-up and half empty.

However, if the module (not just the game) is closed, then restarted, then the log is loaded and clicked through… the round-end procedure can be triggered and works without issue.

The key point here is that nothing is changed between the two situations except for how many times load game > close game has been performed while the module is open. The exact same logs produce different results if loaded immediately after starting the module and if loaded after selecting load game > close game > load game > close game > load game.

I’m guessing that the module is stretching the limits of what Vassal can comfortably handle in one ‘click’, and something is buckling under the strain. The fact that exactly the same actions can result in buggy behaviour or intended behaviour seems to indicate that the fault does not lie in the module itself, but perhaps could be mitigated by cleaning up or reducing the number of triggers and global key commands associated with one action button.

The bugs can be seen in action in the last two logs. The player clicks the round-end button and the decks go haywire. This is replicable by loading and closing the preceding logs, then clicking the round-end button after viewing log4. However, if 2-round4.vlog is loaded as the first save game immediately after starting the module, the round-end button works fine. If anyone wants to test this, the button is on the ‘card offer’ window, and the deck that goes haywire is on the ‘Krang’ window.

Thus spake Benkyo:

An action button pressed after loading and viewing a log (for example,
log4) produces different results (intended or buggy) depending on
whether the log is loaded immediately after starting the module or is
loaded after selecting load game (log1) > close game > load game (log2)

close game > load game (log3) > close game > load game (log4).

I can replicate it, but this module is far too complex for me to
troubleshoot easitly. My hunch is that there’s a static variable
somewhere which is not being reset between loads. If you’d like me
to look into this more, make a cut-down version of the module from
which you’ve removed anything which can be removed while still
preserving the problem.


J.

Thanks for checking it out!

I will work on making a stripped-down module tonight, but testing in Vassal 3.2.13 indicates that even a simple action button > global hotkey > shuffle decks setup will at the very least cause each shuffle to be reported multiple times when a module has been repeatedly closed and loaded, with the number of times increasing as the number of close/load steps increases. Pieces in the decks disappearing seems contingent on this duplication of the global hotkey command reaching some kind of threshold.

I’ve also had reports that the bug can occur during a single continuous game on the Vassal server. The game involved 3 participants and the bug occurred only when clicking the action button > global hotkey > shuffle decks function on the 3rd or 4th occasion, despite the fact that the first two or three times the function worked fine (unfortunately the testers didn’t record whether or not multiple shuffle reports started occurring before the serious bug manifested).

Here’s the test mod:
dropbox.com/s/qkipjbn664js9vw/test2.vmod

There is only a deck of 15 cards (many of which don’t have mask info any more) and a button that shuffles the deck once.
Saving the game, closing then loading the save, then clicking on the button will result in the deck being shuffled twice. Do it again and the button causes the deck to be shuffled three times. The pattern continues. At what point things get overloaded and pieces disappear I do not know, but I think the root of the problem is the global hotkey triggering multiple times.

I can reproduce the problem. I’ve made an even more severely cut-down version of your test module. There’s almost nothing left but the reshuffle button and an empty deck.

Thanks! Here’s hoping for a fix… I believe this is (related to) the bug that has interrupted online and offline games of Mage Knight for well over a year now.

Thus spake Benkyo:

Thanks! Here’s hoping for a fix… I believe this is (related to) the
bug that has interrupted online and offline games of Mage Knight for
well over a year now.

I’ve asked Brent to look at it. One further way you could help would
be to bisect versions of 3.2 for us: I.e., find the first 3.2 release
which has the problem.

The release archive is here:

vassalengine.org/releases/


J.

I have made some progress on this issue.

New Bug Report: Bug 12538 - Decks report multiple shuffles after loading saved game

This particular aspect of the problem was being cause by the Deck adding KeyListeners for shuffle, reshuffle and reverse to the GameModule when a game starts, but not removing them when a game ends. Loading another game causes an additional set of Keylisteners to be added, all of which get fired off when a Shuffle is requested.

I have committed a fix for this specific aspect of the problem to Brent-3.2-Work@9249

This specifically fixes the multiple shuffle issue.

What I do not know is if this will also fix the original problems that resulted in the Deck contents being corrupted. The original test modules are no longer available for download. There may be deeper issues still remaining.

Brent.

Thank you for taking the time to follow-up on this! I deleted my dropbox files after uckelman provided a better test module, but it would be very simple to recreate.

Nice to know that the fix confirms the problem, and why the workaround works.

Hi Benkyo,

Could you please recreate me some files that reproduce issues other than extra shuffle reports. i.e. something actually going wrong like ‘decks disappear or appear face-up and half empty.’ as you originally describe. I can then test it in my debug version to see if those problems are fixed also. I’ll needs some files and a description of how to reproduce the problem.

This will help get the problem solved much faster as I can test issues locally on my PC, but I am dependent on Joel to create distributable Vassal test versions.

Regards,
Brent.

Thus spake Brent Easton:

Hi Benkyo,

Could you please recreate me some files that reproduce issues other than
extra shuffle reports. i.e. something actually going wrong like ‘decks
disappear or appear face-up and half empty.’ as you originally describe.
I can then test it in my debug version to see if those problems are
fixed also. I’ll needs some files and a description of how to reproduce
the problem.

This will help get the problem solved much faster as I can test issues
locally on my PC, but I am dependent on Joel to create distributable
Vassal test versions.

I’ll see about getting you a test build on Saturday.


J.

Thus spake Brent Easton:

Hi Benkyo,

Could you please recreate me some files that reproduce issues other than
extra shuffle reports. i.e. something actually going wrong like ‘decks
disappear or appear face-up and half empty.’ as you originally describe.
I can then test it in my debug version to see if those problems are
fixed also. I’ll needs some files and a description of how to reproduce
the problem.

This will help get the problem solved much faster as I can test issues
locally on my PC, but I am dependent on Joel to create distributable
Vassal test versions.

Try 3.2.18-svn9251:

vassalengine.sourceforge.net/builds/


J.

Sorry, I’m sure it would be very easy to make some example files using the Mage Knight module on the Vassal site, but we’re currently in the process of buying a house, renovating it, and moving, so I probably won’t find the time.