VoidRift / AutoPotion

BSD 3-Clause "New" or "Revised" License
3 stars 2 forks source link

Client crash when enabling Auto Potion on inventory containing multiple Flasks #5

Closed qcoumes closed 1 year ago

qcoumes commented 1 year ago

Hello, I'm running a Calamity Dedicated server, and players crash as soon as the Toggle Auto Potion key is pressed (to enable the auto consumption) if multiple Flasks are in their Auto Potion chosen inventory.

The server does not crash and keeps running perfectly.

Server Config autopotserver

Client Config autopotclient

Server Logs

[17:29:15.281] [Main Thread/WARN] [tML]: Silently Caught Exception: 
System.BadImageFormatException: Read out of bounds.
   at System.Reflection.Throw.OutOfBounds()
   at System.Diagnostics.StackTraceSymbols.GetSourceLineInfo(Assembly assembly, String assemblyPath, IntPtr loadedPeAddress, Int32 loadedPeSize, Boolean isFileLayout, IntPtr inMemoryPdbAddress, Int32 inMemoryPdbSize, Int32 methodToken, Int32 ilOffset, String& sourceFile, Int32& sourceLine, Int32& sourceColumn)
   at System.Diagnostics.StackFrameHelper.InitializeSourceInfo(Int32 iSkip, Boolean fNeedFileInfo, Exception exception)
   at DMD<System.Void System.Diagnostics.StackTrace:CaptureStackTrace(System.Int32, System.Boolean, System.Exception)>(StackTrace this, Int32 skipFrames, Boolean fNeedFileInfo, Exception e)
   at Hook<System.Void Terraria.ModLoader.Engine.LoggingHooks::Hook_StackTrace_CaptureStackTrace(Terraria.ModLoader.Engine.LoggingHooks+orig_StackTrace_CaptureStackTrace,System.Diagnostics.StackTrace,System.Int32,System.Boolean,System.Exception)>(StackTrace , Int32 , Boolean , Exception )
   at SyncProxy<System.Void System.Diagnostics.StackTrace:CaptureStackTrace(System.Int32, System.Boolean, System.Exception)>(StackTrace , Int32 , Boolean , Exception )
   at System.Diagnostics.StackTrace..ctor(Boolean fNeedFileInfo)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.CreateException(SocketError error, Boolean forAsyncThrow)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.SendAsync(Socket socket, CancellationToken cancellationToken)
   at System.Net.Sockets.NetworkStream.BeginWrite(Byte[] buffer, Int32 offset, Int32 count, AsyncCallback callback, Object state)
   at DMD<System.Void Terraria.Net.Sockets.TcpSocket:Terraria.Net.Sockets.ISocket.AsyncSend(System.Byte[], System.Int32, System.Int32, Terraria.Net.Sockets.SocketSendCallback, System.Object)>(TcpSocket this, Byte[] data, Int32 offset, Int32 size, SocketSendCallback callback, Object state)
   at SyncProxy<System.Void Terraria.Net.Sockets.TcpSocket:Terraria.Net.Sockets.ISocket.AsyncSend(System.Byte[], System.Int32, System.Int32, Terraria.Net.Sockets.SocketSendCallback, System.Object)>(TcpSocket , Byte[] , Int32 , Int32 , SocketSendCallback , Object )
   at Terraria.Net.NetManager.SendData(ISocket socket, NetPacket packet)
   at Terraria.GameContent.NetModules.NetLiquidModule.PrepareAndSendToEachPlayerSeparately()
   at Terraria.Liquid.UpdateLiquid()
   at Terraria.WorldGen.UpdateWorld_Inner()
   at DMD<System.Void Terraria.WorldGen:UpdateWorld()>()
   at SyncProxy<System.Void Terraria.WorldGen:UpdateWorld()>()
   at DMD<System.Void Terraria.Main:DoUpdateInWorld(System.Diagnostics.Stopwatch)>(Main this, Stopwatch sw)
   at SyncProxy<System.Void Terraria.Main:DoUpdateInWorld(System.Diagnostics.Stopwatch)>(Main , Stopwatch )
   at Terraria.Main.DoUpdate(GameTime& gameTime)
   at Terraria.Main.Update(GameTime gameTime)
   at DMD<System.Void Terraria.Main:DedServ_PostModLoad(System.Boolean&)>(Main this, Boolean& reloadMods)
   at SyncProxy<System.Void Terraria.Main:DedServ_PostModLoad(System.Boolean&)>(Main , Boolean& )
   at Terraria.Main.DedServ()
   at Terraria.Program.RunGame()
   at Terraria.Program.LaunchGame_(Boolean isServer)
   at Terraria.Program.LaunchGame(String[] args, Boolean monoArgs)
   at Terraria.MonoLaunch.Main_End(String[] args)
   at Terraria.MonoLaunch.<>c__DisplayClass1_0.<Main>b__1()
   at Terraria.MonoLaunch.Main(String[] args)

Client Logs Log has been truncating so as to now create a 5MB post

Setting breakpad minidump AppID = 105600
SteamInternal_SetMinidumpSteamID:  Caching Steam ID:  76561198039671772 [API loaded no]
Setting breakpad minidump AppID = 1281930
SteamInternal_SetMinidumpSteamID:  Caching Steam ID:  76561198039671772 [API loaded no]
Stack overflow.
   at MonoMod.Utils.DynamicReferenceManager.GetCell(MonoMod.Utils.DynamicReferenceCell)
   at DynamicClass.Hook<System.Void AutoPotion.AutoPotionMod::OnAddBuff(Terraria.On_Player+orig_AddBuff,Terraria.Player,System.Int32,System.Int32,System.Boolean,System.Boolean)>(Terraria.On_Player+orig_AddBuff,Terraria.Player,System.Int32,System.Int32,System.Boolean,System.Boolean)>(Terraria.Player, Int32, Int32, Boolean, Boolean)
   at DynamicClass.SyncProxy<System.Void Terraria.Player:AddBuff(System.Int32, System.Int32, System.Boolean, System.Boolean)>(System.Int32, System.Int32, System.Boolean, System.Boolean)>(Terraria.Player, Int32, Int32, Boolean, Boolean)
   at AutoPotion.AutoPotionMod.ConsumePotions()
   at AutoPotion.AutoPotionMod.OnDelBuff(orig_DelBuff, Terraria.Player, Int32)
   at DynamicClass.Hook<System.Void AutoPotion.AutoPotionMod::OnDelBuff(Terraria.On_Player+orig_DelBuff,Terraria.Player,System.Int32)>(Terraria.On_Player+orig_DelBuff,Terraria.Player,System.Int32)>(Terraria.Player, Int32)
   at DynamicClass.SyncProxy<System.Void Terraria.Player:DelBuff(System.Int32)>(System.Int32)>(Terraria.Player, Int32)
   at Terraria.Player.AddBuff_RemoveOldMeleeBuffsOfMatchingType(Int32)
   at DynamicClass.DMD<System.Void Terraria.Player:AddBuff(System.Int32, System.Int32, System.Boolean, System.Boolean)>(System.Int32, System.Int32, System.Boolean, System.Boolean)>(Terraria.Player, Int32, Int32, Boolean, Boolean)
   at DynamicClass.Hook<System.Void AutoPotion.AutoPotionMod::OnAddBuff(Terraria.On_Player+orig_AddBuff,Terraria.Player,System.Int32,System.Int32,System.Boolean,System.Boolean)>(Terraria.On_Player+orig_AddBuff,Terraria.Player,System.Int32,System.Int32,System.Boolean,System.Boolean)>(Terraria.Player, Int32, Int32, Boolean, Boolean)
   at DynamicClass.SyncProxy<System.Void Terraria.Player:AddBuff(System.Int32, System.Int32, System.Boolean, System.Boolean)>(System.Int32, System.Int32, System.Boolean, System.Boolean)>(Terraria.Player, Int32, Int32, Boolean, Boolean)
   at AutoPotion.AutoPotionMod.ConsumePotions()
   at AutoPotion.AutoPotionMod.OnDelBuff(orig_DelBuff, Terraria.Player, Int32)
   at DynamicClass.Hook<System.Void AutoPotion.AutoPotionMod::OnDelBuff(Terraria.On_Player+orig_DelBuff,Terraria.Player,System.Int32)>(Terraria.On_Player+orig_DelBuff,Terraria.Player,System.Int32)>(Terraria.Player, Int32)
   at DynamicClass.SyncProxy<System.Void Terraria.Player:DelBuff(System.Int32)>(System.Int32)>(Terraria.Player, Int32)
   at Terraria.Player.AddBuff_RemoveOldMeleeBuffsOfMatchingType(Int32)
   at DynamicClass.DMD<System.Void Terraria.Player:AddBuff(System.Int32, System.Int32, System.Boolean, System.Boolean)>(System.Int32, System.Int32, System.Boolean, System.Boolean)>(Terraria.Player, Int32, Int32, Boolean, Boolean)
   at DynamicClass.Hook<System.Void AutoPotion.AutoPotionMod::OnAddBuff(Terraria.On_Player+orig_AddBuff,Terraria.Player,System.Int32,System.Int32,System.Boolean,System.Boolean)>(Terraria.On_Player+orig_AddBuff,Terraria.Player,System.Int32,System.Int32,System.Boolean,System.Boolean)>(Terraria.Player, Int32, Int32, Boolean, Boolean)
   at DynamicClass.SyncProxy<System.Void Terraria.Player:AddBuff(System.Int32, System.Int32, System.Boolean, System.Boolean)>(System.Int32, System.Int32, System.Boolean, System.Boolean)>(Terraria.Player, Int32, Int32, Boolean, Boolean)
   at AutoPotion.AutoPotionMod.ConsumePotions()
   at AutoPotion.AutoPotionMod.OnDelBuff(orig_DelBuff, Terraria.Player, Int32)
   at DynamicClass.Hook<System.Void AutoPotion.AutoPotionMod::OnDelBuff(Terraria.On_Player+orig_DelBuff,Terraria.Player,System.Int32)>(Terraria.On_Player+orig_DelBuff,Terraria.Player,System.Int32)>(Terraria.Player, Int32)
   at DynamicClass.SyncProxy<System.Void Terraria.Player:DelBuff(System.Int32)>(System.Int32)>(Terraria.Player, Int32)
   at Terraria.Player.AddBuff_RemoveOldMeleeBuffsOfMatchingType(Int32)
   at DynamicClass.DMD<System.Void Terraria.Player:AddBuff(System.Int32, System.Int32, System.Boolean, System.Boolean)>(System.Int32, System.Int32, System.Boolean, System.Boolean)>(Terraria.Player, Int32, Int32, Boolean, Boolean)
   at DynamicClass.Hook<System.Void AutoPotion.AutoPotionMod::OnAddBuff(Terraria.On_Player+orig_AddBuff,Terraria.Player,System.Int32,System.Int32,System.Boolean,System.Boolean)>(Terraria.On_Player+orig_AddBuff,Terraria.Player,System.Int32,System.Int32,System.Boolean,System.Boolean)>(Terraria.Player, Int32, Int32, Boolean, Boolean)
   at DynamicClass.SyncProxy<System.Void Terraria.Player:AddBuff(System.Int32, System.Int32, System.Boolean, System.Boolean)>(System.Int32, System.Int32, System.Boolean, System.Boolean)>(Terraria.Player, Int32, Int32, Boolean, Boolean)
   at AutoPotion.AutoPotionMod.ConsumePotions()
   at AutoPotion.AutoPotionMod.OnDelBuff(orig_DelBuff, Terraria.Player, Int32)
   at DynamicClass.Hook<System.Void AutoPotion.AutoPotionMod::OnDelBuff(Terraria.On_Player+orig_DelBuff,Terraria.Player,System.Int32)>(Terraria.On_Player+orig_DelBuff,Terraria.Player,System.Int32)>(Terraria.Player, Int32)
   at DynamicClass.SyncProxy<System.Void Terraria.Player:DelBuff(System.Int32)>(System.Int32)>(Terraria.Player, Int32)
   at Terraria.Player.AddBuff_RemoveOldMeleeBuffsOfMatchingType(Int32)
   at DynamicClass.DMD<System.Void Terraria.Player:AddBuff(System.Int32, System.Int32, System.Boolean, System.Boolean)>(System.Int32, System.Int32, System.Boolean, System.Boolean)>(Terraria.Player, Int32, Int32, Boolean, Boolean)
   at DynamicClass.Hook<System.Void AutoPotion.AutoPotionMod::OnAddBuff(Terraria.On_Player+orig_AddBuff,Terraria.Player,System.Int32,System.Int32,System.Boolean,System.Boolean)>(Terraria.On_Player+orig_AddBuff,Terraria.Player,System.Int32,System.Int32,System.Boolean,System.Boolean)>(Terraria.Player, Int32, Int32, Boolean, Boolean)
   at DynamicClass.SyncProxy<System.Void Terraria.Player:AddBuff(System.Int32, System.Int32, System.Boolean, System.Boolean)>(System.Int32, System.Int32, System.Boolean, System.Boolean)>(Terraria.Player, Int32, Int32, Boolean, Boolean)
   at AutoPotion.AutoPotionMod.ConsumePotions()
   at AutoPotion.AutoPotionMod.OnDelBuff(orig_DelBuff, Terraria.Player, Int32)
   at DynamicClass.Hook<System.Void AutoPotion.AutoPotionMod::OnDelBuff(Terraria.On_Player+orig_DelBuff,Terraria.Player,System.Int32)>(Terraria.On_Player+orig_DelBuff,Terraria.Player,System.Int32)>(Terraria.Player, Int32)
   at DynamicClass.SyncProxy<System.Void Terraria.Player:DelBuff(System.Int32)>(System.Int32)>(Terraria.Player, Int32)
   at Terraria.Player.AddBuff_RemoveOldMeleeBuffsOfMatchingType(Int32)
   at DynamicClass.DMD<System.Void Terraria.Player:AddBuff(System.Int32, System.Int32, System.Boolean, System.Boolean)>(System.Int32, System.Int32, System.Boolean, System.Boolean)>(Terraria.Player, Int32, Int32, Boolean, Boolean)
   at DynamicClass.Hook<System.Void AutoPotion.AutoPotionMod::OnAddBuff(Terraria.On_Player+orig_AddBuff,Terraria.Player,System.Int32,System.Int32,System.Boolean,System.Boolean)>(Terraria.On_Player+orig_AddBuff,Terraria.Player,System.Int32,System.Int32,System.Boolean,System.Boolean)>(Terraria.Player, Int32, Int32, Boolean, Boolean)
   at DynamicClass.SyncProxy<System.Void Terraria.Player:AddBuff(System.Int32, System.Int32, System.Boolean, System.Boolean)>(System.Int32, System.Int32, System.Boolean, System.Boolean)>(Terraria.Player, Int32, Int32, Boolean, Boolean)
   at AutoPotion.AutoPotionMod.ConsumePotions()
   at AutoPotion.AutoPotionMod.OnDelBuff(orig_DelBuff, Terraria.Player, Int32)
   at DynamicClass.Hook<System.Void AutoPotion.AutoPotionMod::OnDelBuff(Terraria.On_Player+orig_DelBuff,Terraria.Player,System.Int32)>(Terraria.On_Player+orig_DelBuff,Terraria.Player,System.Int32)>(Terraria.Player, Int32)
   at DynamicClass.SyncProxy<System.Void Terraria.Player:DelBuff(System.Int32)>(System.Int32)>(Terraria.Player, Int32)
   at Terraria.Player.AddBuff_RemoveOldMeleeBuffsOfMatchingType(Int32)
   at DynamicClass.DMD<System.Void Terraria.Player:AddBuff(System.Int32, System.Int32, System.Boolean, System.Boolean)>(System.Int32, System.Int32, System.Boolean, System.Boolean)>(Terraria.Player, Int32, Int32, Boolean, Boolean)
   at DynamicClass.Hook<System.Void AutoPotion.AutoPotionMod::OnAddBuff(Terraria.On_Player+orig_AddBuff,Terraria.Player,System.Int32,System.Int32,System.Boolean,System.Boolean)>(Terraria.On_Player+orig_AddBuff,Terraria.Player,System.Int32,System.Int32,System.Boolean,System.Boolean)>(Terraria.Player, Int32, Int32, Boolean, Boolean)
   at DynamicClass.SyncProxy<System.Void Terraria.Player:AddBuff(System.Int32, System.Int32, System.Boolean, System.Boolean)>(System.Int32, System.Int32, System.Boolean, System.Boolean)>(Terraria.Player, Int32, Int32, Boolean, Boolean)
   at AutoPotion.AutoPotionMod.ConsumePotions()
   at AutoPotion.AutoPotionMod.OnDelBuff(orig_DelBuff, Terraria.Player, Int32)
   at DynamicClass.Hook<System.Void AutoPotion.AutoPotionMod::OnDelBuff(Terraria.On_Player+orig_DelBuff,Terraria.Player,System.Int32)>

[...]

(Terraria.On_Player+orig_DelBuff,Terraria.Player,System.Int32)>(Terraria.Player, Int32)
   at DynamicClass.SyncProxy<System.Void Terraria.Player:DelBuff(System.Int32)>(System.Int32)>(Terraria.Player, Int32)
   at Terraria.Player.AddBuff_RemoveOldMeleeBuffsOfMatchingType(Int32)
   at DynamicClass.DMD<System.Void Terraria.Player:AddBuff(System.Int32, System.Int32, System.Boolean, System.Boolean)>(System.Int32, System.Int32, System.Boolean, System.Boolean)>(Terraria.Player, Int32, Int32, Boolean, Boolean)
   at DynamicClass.Hook<System.Void AutoPotion.AutoPotionMod::OnAddBuff(Terraria.On_Player+orig_AddBuff,Terraria.Player,System.Int32,System.Int32,System.Boolean,System.Boolean)>(Terraria.On_Player+orig_AddBuff,Terraria.Player,System.Int32,System.Int32,System.Boolean,System.Boolean)>(Terraria.Player, Int32, Int32, Boolean, Boolean)
   at DynamicClass.SyncProxy<System.Void Terraria.Player:AddBuff(System.Int32, System.Int32, System.Boolean, System.Boolean)>(System.Int32, System.Int32, System.Boolean, System.Boolean)>(Terraria.Player, Int32, Int32, Boolean, Boolean)
   at AutoPotion.AutoPotionMod.ConsumePotions()
   at AutoPotion.AutoPotionMod.ToggleAutoPotion(Boolean)
   at Terraria.ModLoader.PlayerLoader.ProcessTriggers(Terraria.Player, Terraria.GameInput.TriggersSet)
   at Terraria.GameInput.TriggersSet.CopyInto(Terraria.Player)
   at DynamicClass.DMD<System.Void Terraria.Player:Update(System.Int32)>(System.Int32)>(Terraria.Player, Int32)
   at DynamicClass.SyncProxy<System.Void Terraria.Player:Update(System.Int32)>(System.Int32)>(Terraria.Player, Int32)
   at DynamicClass.DMD<System.Void Terraria.Main:DoUpdateInWorld(System.Diagnostics.Stopwatch)>(System.Diagnostics.Stopwatch)>(Terraria.Main, System.Diagnostics.Stopwatch)
   at DynamicClass.SyncProxy<System.Void Terraria.Main:DoUpdateInWorld(System.Diagnostics.Stopwatch)>(System.Diagnostics.Stopwatch)>(Terraria.Main, System.Diagnostics.Stopwatch)
   at Terraria.Main.DoUpdate(Microsoft.Xna.Framework.GameTime ByRef)
   at Terraria.Main.Update(Microsoft.Xna.Framework.GameTime)
   at Microsoft.Xna.Framework.Game.Tick()
   at Microsoft.Xna.Framework.Game.RunLoop()
   at Microsoft.Xna.Framework.Game.Run()
   at Terraria.Program.RunGame()
   at Terraria.Program.LaunchGame_(Boolean)
   at Terraria.Program.LaunchGame(System.String[], Boolean)
   at Terraria.MonoLaunch.Main_End(System.String[])
   at Terraria.MonoLaunch+<>c__DisplayClass1_0.<Main>b__1()
   at System.Threading.Thread.StartCallback()

The problem seems to be an infinite recursion.

qcoumes commented 1 year ago

After some investigation, it seems the bug has nothing to do with Flask of Crumbling, but occurs when multiple Flask are in the player-chosen inventory.

This may be related to the fact that using a flask overwrites any previous flask.

I edited the first post.

VoidRift commented 1 year ago

Yes only one type of flask can be active at the same time. I thought I caught all flask types but I must of missed some. Will fix it in the next couple of days. In the meantime just having one type of flask in the inventory will fix the problem.

VoidRift commented 1 year ago

I think I fixed the issue with version 0.1.24. If it is not fixed let me know otherwise please close this ticket.

qcoumes commented 1 year ago

I just tested it and it seems fixed. Thanks!