magefree / mage

Magic Another Game Engine
http://xmage.today
MIT License
1.85k stars 761 forks source link

Infinite stack with same ability (wrong choose dialog) #11078

Closed JayDi85 closed 9 months ago

JayDi85 commented 1 year ago

Some card has wrong ability/effect/cost/applies with choose dialog in wrong method and it allows to generate broken stack with inifinite abilities

Only server logs from gameInCheckPlayableState call:

Current stack: 40 - stack ability (Whenever a permanent enters the battlefield tapped and under your control, untap it. Triggered permanent: Bojuka Bog [0eb]),

stack ability (Whenever a permanent enters the battlefield tapped and under your control, untap it. Triggered permanent: Mystic Sanctuary [e90]),

stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.),

... x40 same abilities ...

stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.)

Susucre commented 1 year ago

First two are probably [[Amulet of Vigor]], Zombie one is [[Field of the Dead]].

You plan of fixing them yourself?

github-actions[bot] commented 1 year ago

Amulet of Vigor - (Gatherer) (Scryfall) (EDHREC)

{1} Artifact Whenever a permanent enters the battlefield tapped and under your control, untap it.

Field of the Dead - (Gatherer) (Scryfall) (EDHREC)

Land Field of the Dead enters the battlefield tapped. {T}: Add {C}. Whenever Field of the Dead or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.

JayDi85 commented 1 year ago

You plan of fixing them yourself

Nope, just for info. I don't know the real reason for it.

ssk97 commented 1 year ago

Are you sure it's infinite? Someone playing a Scapeshift deck with multiple Field of the Deads could easily hit >40 triggers at once.

Susucre commented 1 year ago

yeah I did look at the implementation of both cards quickly, and did not see anything catching the eye as "choose dialog in a place it should not be", so I suppose there might be someone actually having a combo deck with lots of the same trigger. Maybe lots of copy of Amulet for the untap one, and indeed Scapeshift on 4 Fields + 6 others lands for 40 triggers. Doubling ETBs multiple times also comes to mind.

JayDi85 commented 1 year ago

Game frozen in infinite loop with 1 Gb logs generation in few minutes due wrong chooseTriggeredAbility call until player disconnected/leave (well, connection problems were first, after was a logs burst).

java.lang.Throwable
    at mage.player.human.HumanPlayer.gameInCheckPlayableState(HumanPlayer.java:2749)
        at mage.player.human.HumanPlayer.gameInCheckPlayableState(HumanPlayer.java:2739)
        at mage.player.human.HumanPlayer.chooseTriggeredAbility(HumanPlayer.java:1314)
        at mage.game.GameImpl.checkTriggered(GameImpl.java:2126)
        at mage.game.GameImpl.checkStateAndTriggered(GameImpl.java:2083)
        at mage.game.GameImpl.playPriority(GameImpl.java:1592)
        at mage.game.turn.Step.priority(Step.java:66)
        at mage.game.turn.Phase.playStep(Phase.java:204)
        at mage.game.turn.Phase.play(Phase.java:90)
        at mage.game.turn.Turn.play(Turn.java:137)
        at mage.game.GameImpl.playTurn(GameImpl.java:1095)
        at mage.game.GameImpl.play(GameImpl.java:1002)
        at mage.game.GameImpl.start(GameImpl.java:978)
        at mage.server.game.GameWorker.call(GameWorker.java:34)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

Possible related game:

INFO  2023-08-28 09:12:50,071 MATCH started [Commander - non casual but not cedh, no extra turns] 42285773-fb12-4ec2-b0c8-dc5eb45367ad(EclipseofAshes) =>[CALL main-1037] TableController.lambda$startMatch$7
INFO  2023-08-28 09:12:50,078 GAME started 6f426625-07e0-4d5b-a665-32a6f66a206e [Commander - non casual but not cedh, no extra turns] ZaneDreadmoore - EclipseofAshes - potanico =>[CALL main-1037] TableController.startGame

WARN  2023-08-28 09:52:41,737 Game frozen in waitResponseOpen for user EclipseofAshes (connection problem)               =>[CALL main-2104] HumanPlayer.waitResponseOpen
INFO  2023-08-28 09:52:42,760 USER REMOVE - ZaneDreadmoore (Disconnected)  userId: 754ddaa8-994a-4ee0-97c1-cae98f8badf9 [Match: 1 ] =>[CALL main-2104] UserManagerImpl.lambda$null$1

INFO  2023-08-28 09:52:53,463 Reconnecting session for ZaneDreadmoore                                                    =>[WorkerThread#279[yyy:58625]] Session.connectUserHandling
INFO  2023-08-28 09:52:53,517 ZaneDreadmoore connected to server                                                         =>[WorkerThread#279[yyy:58625]] SessionManagerImpl.connectUser
WARN  2023-08-28 09:53:07,611 FIX command was called by potanico for game 6f426625-07e0-4d5b-a665-32a6f66a206e - players: EclipseofAshes (play), ZaneDreadmoore (out), potanico (play) =>[CALL main-2066] GameController.attemptToFixGame
WARN  2023-08-28 09:53:07,620 FIX command result for game 6f426625-07e0-4d5b-a665-32a6f66a206e: none                     =>[CALL main-2066] GameController.attemptToFixGame
WARN  2023-08-28 09:54:06,962 Game frozen in waitResponseOpen for user EclipseofAshes (connection problem)               =>[CALL main-2066] HumanPlayer.waitResponseOpen
WARN  2023-08-28 09:54:59,034 Game frozen in waitResponseOpen for user EclipseofAshes (connection problem)               =>[CALL main-2066] HumanPlayer.waitResponseOpen
WARN  2023-08-28 09:55:05,649 Game frozen in waitResponseOpen for user EclipseofAshes (connection problem)               =>[CALL main-2104] HumanPlayer.waitResponseOpen
WARN  2023-08-28 09:55:08,271 Game frozen in waitResponseOpen for user EclipseofAshes (connection problem)               =>[CALL main-2141] HumanPlayer.waitResponseOpen
WARN  2023-08-28 09:55:08,666 Game frozen in waitResponseOpen for user EclipseofAshes (connection problem)               =>[CALL main-2142] HumanPlayer.waitResponseOpen
WARN  2023-08-28 09:55:08,968 Game frozen in waitResponseOpen for user EclipseofAshes (connection problem)               =>[CALL main-2143] HumanPlayer.waitResponseOpen

INFO  2023-08-28 09:57:10,247 Disconnecting another user instance: EclipseofAshes                                        =>[WorkerThread#203[xxx:62513]] Session.connectUserHandling
WARN  2023-08-28 09:57:10,562 Game frozen in waitResponseOpen for user EclipseofAshes (connection problem)               =>[CALL main-2153] HumanPlayer.waitResponseOpen
WARN  2023-08-28 09:57:12,608 Game frozen in waitResponseOpen for user EclipseofAshes (connection problem)               =>[CALL main-2154] HumanPlayer.waitResponseOpen
INFO  2023-08-28 09:57:23,074 USER REMOVE - Pinoclio (Disconnected)  userId: 01aab146-a311-46cd-a745-9b1358ff740c [Match: 1 ] =>[CALL main-2154] UserManagerImpl.lambda$null$1
INFO  2023-08-28 09:57:34,407 USER REMOVE - Mr_Fox (Disconnected)  userId: 8b8a8aa4-774b-47d7-b077-3569ba5d9efa []       =>[CALL main-2206] UserManagerImpl.lambda$null$1
INFO  2023-08-28 09:57:35,700 Disconnecting another user instance: EclipseofAshes                                        =>[WorkerThread#17[xxx:62520]] Session.connectUserHandling

INFO  2023-08-28 09:57:55,086 Reconnecting session for Pinoclio                                                          =>[WorkerThread#230[zzz:52083]] Session.connectUserHandling
INFO  2023-08-28 09:57:55,259 Pinoclio connected to server                                                               =>[WorkerThread#230[zzz:52083]] SessionManagerImpl.connectUser
INFO  2023-08-28 09:58:18,443 INFORM OPPONENTS by EclipseofAshes: EclipseofAshes got connection problem for 42 secs      =>[CALL main-2206] ChatManagerImpl.lambda$sendMessageToUserChats$10
INFO  2023-08-28 09:58:21,939 USER REMOVE - ZaneDreadmoore (Disconnected)  userId: 754ddaa8-994a-4ee0-97c1-cae98f8badf9 [] =>[CALL main-2206] UserManagerImpl.lambda$null$1

INFO  2023-08-28 09:59:18,443 INFORM OPPONENTS by EclipseofAshes: EclipseofAshes got connection problem for 102 secs     =>[CALL main-2229] ChatManagerImpl.lambda$sendMessageToUserChats$10

INFO  2023-08-28 10:00:18,442 INFORM OPPONENTS by EclipseofAshes: EclipseofAshes got connection problem for 162 secs     =>[CALL main-2229] ChatManagerImpl.lambda$sendMessageToUserChats$10
INFO  2023-08-28 10:00:19,615 EclipseofAshes connected to server                                                         =>[WorkerThread#203[xxx:62513]] SessionManagerImpl.connectUser
WARN  2023-08-28 10:00:19,628 Current stack: 40 - stack ability (Whenever a permanent enters the battlefield tapped and under your control, untap it. Triggered permanent: <font color='#94A4BA'>Bojuka Bog [0eb]</font>), stack ability (Whenever a permanent enters the battlefield tapped and under your control, untap it. Triggered permanent: <font color='#94A4BA'>Mystic Sanctuary [e90]</font>), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.), stack ability (Whenever {this} or another land enters the battlefield under your control, if you control seven or more lands with different names, create a 2/2 black Zombie creature token.) =>[GAME 6f426625-07e0-4d5b-a665-32a6f66a206e] HumanPlayer.gameInCheckPlayableState
WARN  2023-08-28 10:00:19,629 Player interaction in checkPlayableState                                                   =>[GAME 6f426625-07e0-4d5b-a665-32a6f66a206e] HumanPlayer.gameInCheckPlayableState
java.lang.Throwable
    at mage.player.human.HumanPlayer.gameInCheckPlayableState(HumanPlayer.java:2749)
    at mage.player.human.HumanPlayer.gameInCheckPlayableState(HumanPlayer.java:2739)
    at mage.player.human.HumanPlayer.chooseTriggeredAbility(HumanPlayer.java:1314)
    at mage.game.GameImpl.checkTriggered(GameImpl.java:2126)
    at mage.game.GameImpl.checkStateAndTriggered(GameImpl.java:2083)
    at mage.game.GameImpl.playPriority(GameImpl.java:1592)
    at mage.game.turn.Step.priority(Step.java:66)
    at mage.game.turn.Phase.playStep(Phase.java:204)
    at mage.game.turn.Phase.play(Phase.java:90)

INFO  2023-08-28 10:01:18,443 INFORM OPPONENTS by EclipseofAshes: EclipseofAshes got connection problem for 222 secs     =>[CALL main-2229] ChatManagerImpl.lambda$sendMessageToUserChats$10
INFO  2023-08-28 10:01:18,442 USER REMOVE - EclipseofAshes (SessionExpired)  userId: 6676b09f-8e4d-48cf-a7a3-29f746a3ba15 [Match: 1 ] =>[CALL main-2263] UserManagerImpl.lambda$null$1
WARN  2023-08-28 10:01:18,444 Player interaction in checkPlayableState                                                   =>[GAME 6f426625-07e0-4d5b-a665-32a6f66a206e] HumanPlayer.gameInCheckPlayableState
java.lang.Throwable
    at mage.player.human.HumanPlayer.gameInCheckPlayableState(HumanPlayer.java:2749)
    at mage.player.human.HumanPlayer.gameInCheckPlayableState(HumanPlayer.java:2739)
    at mage.player.human.HumanPlayer.chooseTriggeredAbility(HumanPlayer.java:1314)
    at mage.game.GameImpl.checkTriggered(GameImpl.java:2126)
    at mage.game.GameImpl.checkStateAndTriggered(GameImpl.java:2083)
    at mage.game.GameImpl.playPriority(GameImpl.java:1592)
    at mage.game.turn.Step.priority(Step.java:66)
    at mage.game.turn.Phase.playStep(Phase.java:204)
    at mage.game.turn.Phase.play(Phase.java:90)

INFO  2023-08-28 10:01:18,472 EclipseofAshes connected to server                                                         =>[WorkerThread#17[xxx:62520]] SessionManagerImpl.connectUser
INFO  2023-08-28 10:01:23,550 LOST CONNECTION - EclipseofAshes [] at xxx sessionId: 4sm401-6mdts3-llunkp5n-1-lluph74t-e =>[Timer-0] Main$ClientConnectionListener.handleConnectionException
INFO  2023-08-28 10:01:25,873 USER REMOVE - potanico (Disconnected)  userId: 47b3775d-11e3-44a5-9ece-b8f5a290119e []     =>[CALL main-2263] UserManagerImpl.lambda$null$1

INFO  2023-08-28 10:02:18,443 USER REMOVE - EclipseofAshes (SessionExpired)  userId: 6676b09f-8e4d-48cf-a7a3-29f746a3ba15 [] =>[CALL main-2229] UserManagerImpl.lambda$null$1
Susucre commented 1 year ago

Ok, that's a lot and worth looking into.

JayDi85 commented 1 year ago

What's gameInCheckPlayableState:

Susucre commented 1 year ago

Actually this is the same stack trace as what could be the cause of #11052, might those be related?

I'm currently trying to see if I can break stuff with Scapeshift for a lot of ETB trigger.

Susucre commented 1 year ago

image

For now, no success on replicating. Might be another replacement effect around.

JayDi85 commented 1 year ago

BTW another possible reason for a game freeze: infinite cycle with while. It must process empty result in choose dialog call to exit from it on player's disconnection or on same wrong AI choices:

shot_230831_141442

JayDi85 commented 1 year ago

@Susucre can you test it with client's disconnection on choose trigger dialog? You can run multiple clients with diff user names and play same game.

Susucre commented 1 year ago

Sure I'll do that. I'm also trying to contact the players on Discord/beta server, to see if they have logs or remember the board.

JayDi85 commented 1 year ago

For disconnection test -- you must close client app from a task manager. If you close it by disconnect or by windows close button then server can receive disconnect command and process it. Disconnection by timeout must be more buggy for a server.

Susucre commented 1 year ago

Ok this is weird, disconnecting the player casting the Scapeshift before stacking triggers, then reconnecting with that player.

Other player seems normal to me. image Reconnecting player has no GameView, just choose triggers image

Susucre commented 1 year ago

Ok got some info from EclipseofAshes, apparently no log found, but the following cards may be involved: image

Susucre commented 1 year ago

Thanks for the logs, but those one did not seem to be the crash ones. There might either be a card we're missing that interacted poorly (choice during checkTrigger for instance), or it is a disconnect at a very bad time that messed up the game state.

spjspj commented 1 year ago

Ok got some info from EclipseofAshes, apparently no log found, but the following cards may be involved: image

Sorry, don't have the log file for the game JayDi85 mentioned. I have splendid reclamation and eerie ultimatum in the deck.

Susucre commented 1 year ago

Oh that's you then? Can you post or upload the decklist, I'll check the code of each card in it. Might be another player's card that interacted badly there, but checking your deck is a start.

spjspj commented 1 year ago

Academy Ruins;Amulet of Vigor;Bayou;Bojuka Bog;Burgeoning;Cabal Coffers;Chromatic Lantern;Coalition Relic;Collective Restraint;Crop Rotation;Crucible of Worlds;Cultivate;Cyclonic Rift;Demonic Tutor;Doubling Season;Dryad of the Ilysian Grove;Eerie Ultimatum;Enchanted Evening;Exploration;Explosive Vegetation;Fabricate;Field of the Dead;3 Forest;Gaea's Cradle;Glacial Chasm;Godless Shrine;Heroic Intervention;Inventors' Fair;2 Island;Kodama's Reach;Leyline of Anticipation;Mana Crypt;Mana Reflection;Mana Vault;Mirari's Wake;Misty Rainforest;Mystic Sanctuary;Mystical Tutor;New Frontiers;Nyxbloom Ancient;Open the Vaults;Overgrown Tomb;Phyrexian Tower;Plains;Planar Bridge;Planar Portal;Prismatic Vista;Privileged Position;Ramunap Excavator;Replenish;Reshape the Earth;Rite of Replication;Rootpath Purifier;Savannah;Scrubland;Search for Tomorrow;Seedborn Muse;Serra's Sanctum;Smothering Tithe;Sol Ring;Solemn Simulacrum;Splendid Reclamation;Sterling Grove;Swamp;Teferi's Protection;The World Tree;Thrasios, Triton Hero;Three Visits;Timeless Witness;Traumatize;Tropical Island;Tundra;Underground Sea;Unwinding Clock;Urborg, Tomb of Yawgmoth;Vampiric Tutor;Verdant Catacombs;Watery Grave;Wayward Swordtooth;Windfall;Worldly Tutor;Yavimaya, Cradle of Growth;World Shaper;Farhaven Elf;Earthcraft;Land Tax;Elixir of Immortality;Demolition Field;Fabled Passage;Treasure Vault;Warp World;Boseiju, Who Shelters All;Beast Within;Taiga;The Tabernacle at Pendrell Vale;Mana Web;SB: Kenrith, the Returned King; << deck list.

JayDi85 commented 9 months ago

No reproducible use case, no more overflow error in server logs.