{"action":"created","issue":{"url":"https://api.github.com/repos/sinkillerj/ProjectE/issues/715","labels_url":"https://api.github.com/repos/sinkillerj/ProjectE/issues/715/labels{/name}","comments_url":"https://api.github.com/repos/sinkillerj/ProjectE/issues/715/comments","events_url":"https://api.github.com/repos/sinkillerj/ProjectE/issues/715/events","html_url":"https://github.com/sinkillerj/ProjectE/issues/715","id":76172185,"number":715,"title":"Musing about Transmutation and Alchemy Bag Inventory Wipes","user":{"login":"williewillus","id":2015032,"avatar_url":"https://avatars.githubusercontent.com/u/2015032?v=3","gravatar_id":"","url":"https://api.github.com/users/williewillus","html_url":"https://github.com/williewillus","followers_url":"https://api.github.com/users/williewillus/followers","following_url":"https://api.github.com/users/williewillus/following{/other_user}","gists_url":"https://api.github.com/users/williewillus/gists{/gist_id}","starred_url":"https://api.github.com/users/williewillus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/williewillus/subscriptions","organizations_url":"https://api.github.com/users/williewillus/orgs","repos_url":"https://api.github.com/users/williewillus/repos","events_url":"https://api.github.com/users/williewillus/events{/privacy}","received_events_url":"https://api.github.com/users/williewillus/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-14T00:14:44Z","updated_at":"2015-06-05T12:21:37Z","closed_at":null,"body":"I'm just putting this here so other devs / people can look at it and so I can get it down before I forget.\r\n\r\nAlchemicalBags is a completely static class. It does not use an object instance to store bag inventories - it stores things in a static `Map<String, Map<Byte, ItemStack[]>>`. This is fine for dedicated server-client environments, but I think it might possibly cause a race condition on the IntegratedServer-Client environment because both client and server threads are operating on the **same instance** of the data.\r\n\r\nHere's how it goes in my head (for a bag, but I think the transmutation is the same, just even more rare)\r\n* Lots of items are flowing into the bag via a Black Hole Band (for example). Each time an item enters the bag, the server thread calls AlchemicalBags.set() and AlchemicalBags.sync(). The former sets the aforementioned static map, updated with the latest changes. The latter dispatches the new data to the client.\r\n\r\n* In the Dedicated Server and Client environment, the clientside simply accepts any sync packets and updates the clientside AlchemicalBags static map using set().\r\n\r\n* In the Integrated Server / SSP environment, the server calls set() on the static map accessed by both the client and server threads. Then, the server sends a sync packet, which the client happily accepts and calls set() using the contained data on the SAME static map. Since this is the loopback interface, the packet should arrive really really really fast. But if it does go wonky for a moment, it could turn out like this:\r\n    * Server thread calls set(), then calls sync(), sending a loopback packet to the clientside.\r\n    * Packet lags for some reason or client thread lags. In the meantime, server thread has called set() again.\r\n    * Client catches up and processes packet. It calls set() to update. But since AlchemicalBags is static, we're operating on the exact same object that the server thread just updated, and overwriting it with older data. \r\n\r\n* This is really rare since the loopback interface is blind fast, but I think it matches with reports of it happening on single player (how many of our data wipe bugs are SP vs MP?) and with BHB's or GOED's (where the bag is getting set() called on it extremely often)."},"comment":{"url":"https://api.github.com/repos/sinkillerj/ProjectE/issues/comments/109275273","html_url":"https://github.com/sinkillerj/ProjectE/issues/715#issuecomment-109275273","issue_url":"https://api.github.com/repos/sinkillerj/ProjectE/issues/715","id":109275273,"user":{"login":"Heimdell","id":1784505,"avatar_url":"https://avatars.githubusercontent.com/u/1784505?v=3","gravatar_id":"","url":"https://api.github.com/users/Heimdell","html_url":"https://github.com/Heimdell","followers_url":"https://api.github.com/users/Heimdell/followers","following_url":"https://api.github.com/users/Heimdell/following{/other_user}","gists_url":"https://api.github.com/users/Heimdell/gists{/gist_id}","starred_url":"https://api.github.com/users/Heimdell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Heimdell/subscriptions","organizations_url":"https://api.github.com/users/Heimdell/orgs","repos_url":"https://api.github.com/users/Heimdell/repos","events_url":"https://api.github.com/users/Heimdell/events{/privacy}","received_events_url":"https://api.github.com/users/Heimdell/received_events","type":"User","site_admin":false},"created_at":"2015-06-05T12:21:37Z","updated_at":"2015-06-05T12:21:37Z","body":"Could it be possible that for some reason the `moze_intel.projecte.playerDataAlchemicalBags.loadFromNBT(...)` \r\nreceives invalid or broken `NBTTagCompound` (with field `\"player\"` missing, for instance)?\r\nThere is no validation logic at all there.\r\n\r\nP.S.: I had never encountered that bug, btw (I have last version released and carry my thaumcraft stuff in white bag)."}}