SpongeForge icon indicating copy to clipboard operation
SpongeForge copied to clipboard

[Bug] Redstone neighbours update tracking result in StackOverflowError

Open sandtechnology opened this issue 5 years ago • 8 comments
trafficstars

I am currently running

  • SpongeForge version: 1.12.2-2838-7.1.10

  • Forge version: 14.23.5.2838

  • Java version: 1.8.0_221

  • Operating System: Windows Server 2012 R2 (amd64) version 6.3

  • Plugins/Mods:

  • Plugins (13): Minecraft, Minecraft Coder Pack, SpongeAPI, Sponge, DupeFixer, EconomyLite, FlexibleLogin, LuckPerms, Nucleus, OfflineServerUsernameWebRequestNetworkManager, SoulLaggRemover, SpongeLoginFix, WorldEdit

  • Mods (75): Minecraft, Minecraft Coder Pack, Forge Mod Loader, Minecraft Forge, SpongeAPI, Sponge, Advanced Solar Panels, AppleCore, AppleSkin, Applied Energistics 2, ArmorStatusHUD, Armourer's Workshop, Baubles, Better Nether, Better Survival, BuildCraft, BuildCraft Builders, BuildCraft Compat, BuildCraft Energy, BuildCraft Factory, BuildCraft Lib, BuildCraft Robotics, BuildCraft Silicon, BuildCraft Transport, Clumps, CoFH Core, CodeChicken Lib, CraftStudio API, Dynamic Surroundings, EnderStorage, Example Mod, FoamFix, FoamFixCore, Forge Microblocks, Forge Multipart CBE, Gravitation Suite, Immersive Engineering, Immersive Petroleum, In-game NBTEdit, IndustrialCraft 2, Infernal Mobs, Inventory Tweaks, Iron Chest, Just Enough Characters, Just Enough Energistics, Just Enough Items, Just Enough Pattern Banners, MalisisCore, MalisisDoors, Mekanism, Mekanism: Generators, Minecraft Multipart Plugin, Modern Warfare 2.0 Contagion, NegroeRouse, NoMoreRecipeConflict, Not Enough Items, OpenBlocks, OpenModsLib, OpenModsLib Core, OreLib Support Mod, Phosphor Lighting Engine, Realistic Terrain Generation, Redstone Flux, Roguelike Dungeons, Shadowfacts' Forgelin, SlashBlade, SlashBlade Japanese Addon Pack, SpongeForge, The Twilight Forest, Translocators, Tree Chopper, Waila, What Are We Looking At, WirelessRedstone-CBE, bspkrsCore

Issue Description Redstone casuing StackOverflowError, the redstone wires in this location as followed: TIM图片20200304010754.png

Look like it ONLY trigger when a mob active the pressure plate.

Updated: Reproduce with Only install Nucleus-1.14.2-S7.1-MC1.12.2

Updated: After troubleshooting and searching, I found the root cause is Sponge does not cancel neighbours update when cancelled ChangeBlockEvent (Related code in Nucleus), it also a performance issue to track this.

For Nucleus users, you can disable mob-griefing protection and use gamerule instead to fix it temporary.

full server log and crash-report (forced stop by watchdog):https://gist.github.com/sandtechnology/017ccb13c2c24fdcd7b347127ee80610

sandtechnology avatar Mar 03 '20 17:03 sandtechnology

Can reproduce on SF 4007, using the following listener (mostly copied from the Nucleus code linked above):

    @Listener
    @Exclude({ChangeBlockEvent.Grow.class, ChangeBlockEvent.Decay.class})
    public void onMobChangeBlock(ChangeBlockEvent event, @Root Living living) {
        if (living instanceof Player) {
            return;
        }

        // If the entity is not in the whitelist, then cancel the event.
        event.setCancelled(true);
    }

JBYoshi avatar Mar 27 '20 21:03 JBYoshi

What I've found so far:

  1. When a mob steps on the pressure plates (it may take some moving around for this to trigger), the pressure plate code first sets the block - without triggering any events - then manually causes a neighbor update.
  2. The redstone below the pressure plate receives the neighbor update. Seeing that the pressure plate above is active, it attempts to turn on.
  3. The redstone attempts to change its state in the world, which immediately fires an event. Since the event is cancelled, the power does not actually change.
  4. The redstone also queues itself and all neighboring redstone blocks for another update, and then sends neighbor updates to all of them.
  5. The neighbor updates repeat, passing between the various redstone wire blocks, until the stack overflows.

JBYoshi avatar Mar 27 '20 21:03 JBYoshi

@JBYoshi listen for the neighbor notification event, those ought to be cancelled as well, or if enhanced tracking is enabled, then it should very well be trying to discord the neighbor updates. There's a few gotchas with how Redstone works (as the issue is describing) and it comes down to block changes causing neighbor updates versus the blocks themselves receiving neighbor updates and the blocks calling to schedule more updates.

gabizou avatar Mar 28 '20 22:03 gabizou

So is this a problem on the plugin side? I copied my test code pretty much straight from Nucleus.

JBYoshi avatar Apr 25 '20 18:04 JBYoshi

@sandtechnology Hello I am currently having this issue on my server too. You say you can temporarily fix it by disabling mob griefing protection. You say this is a temporary fix? By that due you mean it stops it from happening for a certain amount of time or what? Any help would be great as this is currently what is preventing me from updating to the latest sponge on my server.

Thanks!

liampearson96 avatar Apr 28 '20 09:04 liampearson96

Just is a workaround, I have no idea when they fixed it, and not sure started from which version will cause this.

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10

From: Liam Pearsonmailto:[email protected] Sent: 2020年4月28日 17:49 To: SpongePowered/SpongeForgemailto:[email protected] Cc: sandtechnologymailto:[email protected]; Mentionmailto:[email protected] Subject: Re: [SpongePowered/SpongeForge] [Bug] Redstone neighbours update tracking result in StackOverflowError (#3098)

@sandtechnologyhttps://github.com/sandtechnology Hello I am currently having this issue on my server too. You say you can temporarily fix it by disabling mob griefing protection. You say this is a temporary fix? By that due you mean it stops it from happening for a certain amount of time or what? Any help would be great as this is currently what is preventing me from updating to the latest sponge on my server.

Thanks!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/SpongePowered/SpongeForge/issues/3098#issuecomment-620500838, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AE3YYCZ33UFULB3RW4ZAEDTRO2REJANCNFSM4LAPCS3Q.

sandtechnology avatar Apr 28 '20 10:04 sandtechnology

@sandtechnology upon trying 'For Nucleus users, you can disable mob-griefing protection and use gamerule instead to fix it temporary' this no longer works. I can confirm the server will still stall even with these settings applied.

So still unknown.

liampearson96 avatar Apr 28 '20 11:04 liampearson96

@sandtechnology upon trying 'For Nucleus users, you can disable mob-griefing protection and use gamerule instead to fix it temporary' this no longer works. I can confirm the server will still stall even with these settings applied.

So still unknown.

Other Plugin which listening ChangeBlockEvent and cancelled it will caused this, so the most best way is waiting the fix.

sandtechnology avatar Apr 28 '20 11:04 sandtechnology