Closed Grifthegnome closed 8 months ago
This is hitting the add entity to ledger a second time issue. It occurred immediately after I connected to the server. Could it be that the player is not being properly removed from the array on disconnect?
I think I've confirmed this. Disconnecting, waiting some time, then reconnecting seems to crash the server.
I just noticed that this isn't related to the player entity, as it is occurring at ExpandedAiTasks.Managers.EntityLedger.AddEntityItemToLedger(Entity entity). This means that it is a loose item that is causing the issue when the player connects to the server.
We may want to modify the logic so that if an entity ID is added twice, we add the entity at the same location in the ledger as the first addition and assert that the first entity addition matches the second one.
This occurred at runtime. Eric was traveling to our fireclay mine. He was not interacting with any items. I am starting to think it is possible for two entities to have the same entity ID and have one loaded from memory.
Process terminated. Assertion failed.
at ExpandedAiTasks.Managers.EntityLedger.AddEntityItemToLedger(Entity entity)
at ExpandedAiTasks.Managers.EntityManager.RegisterEntityWithEntityLedger(Entity entity)
at ExpandedAiTasks.AfterInitializedOverride.OverrideAfterInitialized(Entity __instance, Boolean onFirstSpawn)
at Vintagestory.API.Common.Entities.Entity.AfterInitialized_Patch1(Entity this, Boolean onFirstSpawn)
at Vintagestory.Server.ServerMain.LoadEntity(Entity entity, Int64 fromChunkIndex3d) in C:\Users\Tyron\Documents\vintagestory\game\VintagestoryLib\Server\ServerMain.cs:line 2255
at Vintagestory.Server.ServerSystemSupplyChunks.mainThreadLoadChunkColumn(ChunkColumnLoadRequest chunkRequest) in C:\Users\Tyron\Documents\vintagestory\game\VintagestoryLib\Server\Systems\World\LoadThread\SupplyChunks.cs:line 834
at Vintagestory.Server.ServerSystemSupplyChunks.<>cDisplayClass15_0.
We have figured out that old entities in saved chunks can have the same Entity ID as a different loaded entity, when this happens, the loaded entity is deleted. However this results in cases where two entity IDs can match, but the entity's are not the same. We are trying to account for this by now checking if the IDs match and then only asserting if the entities match. This is messy, but in theory, any loaded Entity with a dupe ID will get added to the ledger, marked for delete, and purged on the next ledger check.
I made changes to fix this for Entity, EntityItem, and Entity Projectile. We have not hit a crash since the fix went in.
Process terminated. Assertion failed. at ExpandedAiTasks.Managers.EntityLedger.AddEntityItemToLedger(Entity entity) at ExpandedAiTasks.Managers.EntityManager.RegisterEntityWithEntityLedger(Entity entity) at ExpandedAiTasks.AfterInitializedOverride.OverrideAfterInitialized(Entity __instance, Boolean onFirstSpawn) at Vintagestory.API.Common.Entities.Entity.AfterInitialized_Patch1(Entity this, Boolean onFirstSpawn) at Vintagestory.Server.ServerMain.LoadEntity(Entity entity, Int64 fromChunkIndex3d) in C:\Users\Tyron\Documents\vintagestory\game\VintagestoryLib\Server\ServerMain.cs:line 2255 at Vintagestory.Server.ServerSystemSupplyChunks.mainThreadLoadChunkColumn(ChunkColumnLoadRequest chunkRequest) in C:\Users\Tyron\Documents\vintagestory\game\VintagestoryLib\Server\Systems\World\LoadThread\SupplyChunks.cs:line 834 at Vintagestory.Server.ServerSystemSupplyChunks.<>cDisplayClass15_0.b 0() in C:\Users\Tyron\Documents\vintagestory\game\VintagestoryLib\Server\Systems\World\LoadThread\SupplyChunks.cs:line 687
at Vintagestory.Server.ServerMain.ProcessMainThreadTasks() in C:\Users\Tyron\Documents\vintagestory\game\VintagestoryLib\Server\ServerMain.cs:line 2774
at Vintagestory.Server.ServerMain.ProcessMain() in C:\Users\Tyron\Documents\vintagestory\game\VintagestoryLib\Server\ServerMain.cs:line 899
at Vintagestory.Server.ServerMain.Process() in C:\Users\Tyron\Documents\vintagestory\game\VintagestoryLib\Server\ServerMain.cs:line 831
at Vintagestory.Server.ServerProgram.Main() in C:\Users\Tyron\Documents\vintagestory\game\VintagestoryLib\Server\ServerProgram.cs:line 128
at Vintagestory.ClientNative.CrashReporter.Start(ThreadStart start) in C:\Users\Tyron\Documents\vintagestory\game\VintagestoryLib\Client\ClientPlatform\ClientNative\CrashReporter.cs:line 93
at Vintagestory.Server.ServerProgram..ctor() in C:\Users\Tyron\Documents\vintagestory\game\VintagestoryLib\Server\ServerProgram.cs:line 90
at Vintagestory.Server.ServerProgram.Main(String[] args) in C:\Users\Tyron\Documents\vintagestory\game\VintagestoryLib\Server\ServerProgram.cs:line 34
at VintagestoryServerLinux.ServerLinux.Main(String[] args) in C:\Users\Tyron\Documents\vintagestory\game\VintagestoryServer\Linux\ServerLinux.cs:line 9
/home/322175/start-vintage-story.sh: line 11: 9 Aborted (core dumped) ./VintagestoryServer --dataPath /home/322175/userdata/vintage-story/data --port=47038 0<&0