GregTechCEu Modern

GregTechCEu Modern

6M Downloads

Endless loop in server side

Phoupraw opened this issue ยท 3 comments

commented

Checked for existing issues

  • I have checked for existing issues, and have found none.

Tested latest version

  • I have checked that this occurs on the latest version.

GregTech CEu Version

7.1.0-SNAPSHOT+20250805-092112-044f801

Minecraft Version

1.21.1 NeoForge

Recipe Viewer Installed

EMI

Environment

Singleplayer

Cross-Mod Interaction

Unsure

Other Installed Mods

  • Advanced AE 1.2.5-1.21.1 (advanced_ae)
  • AdvancedLootInfo 1.21.1-1.2.3 (ali)
  • Advancement Always Announce 0.0.1 (advancementalwaysannounce)
  • Advancements Reloaded 0.6.1 (advancements_reloaded)
  • AE Super Fuzzy 0.3.3 (aesuperfuzzy)
  • AE Terminal Sorter 0.0.2 (aeterminalsorter)
  • AE2 EMI Fix 0.0.1 (ae2emifix)
  • AE2 Import Export Card 1.21-1.4.0 (ae2importexportcard)
  • AE2 Labeled Patterns 1.0.4 (ae2labeledpatterns)
  • AE2 Wireless Terminals Tweaks 0.0.1 (ae2wirelessterminalstweaks)
  • AE2:Crafting Tree 1.21.1-1.0.6 (ae2ct)
  • AE2WTLib 19.2.3 (ae2wtlib)
  • AE2WTLib API 19.2.3 (ae2wtlib_api)
  • Always Eat 1.0.0 (always_eat)
  • AlwaysOpenWater 1.21.1-1.0.1 (aow)
  • Ancient Reforging 1.7 (ancientreforging)
  • Anvil Restoration 2.4 (anvilrestoration)
  • Anvil Swapper 1.2.0 (anvil_swapper)
  • Apotheosis 8.3.6 (apotheosis)
  • Apothic Attributes 2.9.0 (apothic_attributes)
  • Apothic Enchanting 1.4.4 (apothic_enchanting)
  • Apothic Spawners 1.3.2 (apothic_spawners)
  • AppleSkin 3.0.5+mc1.21 (appleskin)
  • Applied Energistics 2 19.2.13 (ae2)
  • Architectury 13.0.8 (architectury)
  • AutoFish 1.0.4 (autofish)
  • AutomaticMemories 1.1.1 (automaticmemories)
  • Balm 21.0.46 (balm)
  • Better Impaling 3.1 (better_impaling)
  • blue_endless_jankson 91.2.3 (blue_endless_jankson)
  • BoccHUD 0.2.2-mc1.21.1 (bocchud)
  • Bookshelf 21.1.57 (bookshelf)
  • Chest Loot Scatter 0.0.1 (chestlootscatter)
  • Client Attribute Limiter 0.0.1 (clientattributelimiter)
  • Client Automatic Doors 0.3.0 (client_auto_door)
  • Client Simple Watchdog 0.3.3 (clientsimplewatchdog)
  • Client Trifle - Auto Combat 0.2.0 (clienttrifle_autocombat)
  • Client Trifle - Block Finder 0.1.3 (clienttrifle_blockfinder)
  • Client Trifle - Block Listener 0.4.1 (clienttrifle_blocklistener)
  • Client Trifle - Brightness 0.0.3 (clienttrifle_brightness)
  • Client Trifle - Entities Glowing 0.0.1 (clienttrifle_entitiesglowing)
  • Client Trifle - MiningDelay 0.1.0 (clienttrifle_miningdelay)
  • Client Trifle - No Slow 0.1.0 (clienttrifle_noslow)
  • Client Trifle - Step Higher 0.1.1 (clienttrifle_stephigher)
  • Client Trifle - Tick Rate 0.0.1 (clienttrifle_tickrate)
  • Client Trifle - Ultra Speed 0.2.0 (clienttrifle_ultraspeed)
  • Client Trifle - Water Walk 0.1.0 (clienttrifle_waterwalk)
  • Client Trifle - X Speed Motion 0.2.0 (clienttrifle_xspeedmotion)
  • Cloth Config v15 API 15.0.140 (cloth_config)
  • Collective 8.3 (collective)
  • Configuration 3.1.1 (configuration)
  • Connector Extras 1.12.1+1.21.1 (connectorextras)
  • Connector Extras EMI Bridge 1.12.1+1.21.1 (connectorextras_emi_bridge)
  • Connector Extras Energy Bridge 1.12.1+1.21.1 (connectorextras_energy_bridge)
  • Connector Extras JEI Bridge 1.12.1+1.21.1 (connectorextras_jei_bridge)
  • Connector Extras KubeJS Bridge 1.12.1+1.21.1 (connectorextras_kubejs_bridge)
  • Connector Extras ModMenu Bridge 1.12.1+1.21.1 (connectorextras_modmenu_bridge)
  • Connector Extras Pehkui Bridge 1.12.1+1.21.1 (connectorextras_pehkui_bridge)
  • Connector Extras REI Bridge 1.12.1+1.21.1 (connectorextras_rei_bridge)
  • Connector Extras Terrablender Bridge 1.12.1+1.21.1 (connectorextras_terrablender_bridge)
  • Creative Flying Tweaks 0.0.1 (creativeflyingtweaks)
  • CreativeCore 2.13.5 (creativecore)
  • Curios API 9.4.2+1.21.1 (curios)
  • Deimos 2.2 (deimos)
  • Ding 1.5.0 (ding)
  • Dynamic FPS 3.9.3 (dynamic_fps)
  • EMI 1.1.22+1.21.1+neoforge (emi)
  • ExMI Actually Additions 1.0.2+1.21.1 (extra_mod_integrations_actually_additions)
  • ExMI Chipped 1.0.2+1.21.1 (extra_mod_integrations_chipped)
  • ExMI Farmer's Delight 1.0.2+1.21.1 (extra_mod_integrations_farmers_delight)
  • ExMI Iron's Spells 'n Spellbooks 1.0.2+1.21.1 (extra_mod_integrations_irons_spellbooks)
  • ExMI PneumaticCraft 1.0.2+1.21.1 (extra_mod_integrations_pneumaticcraft)
  • ExMI Rechiseled 1.0.2+1.21.1 (extra_mod_integrations_rechiseled)
  • ExMI Reliquary 1.0.2+1.21.1 (extra_mod_integrations_reliquary)
  • EXP Counter 2.1 (expcounter)
  • Expanded AE 2.0.8 (expandedae)
  • Expanded Axe Enchanting 1.0.11 (expanded_axe_enchanting)
  • Expanded Bow Enchanting 1.1.2 (expanded_bow_enchanting)
  • Expanded Weapon Enchanting 1.1.1 (expanded_weapon_enchanting)
  • Experience Durability 0.0.1 (experiencedurability)
  • ExtendedAE 1.21-2.2.15-neoforge (extendedae)
  • Extra Mod Integrations 1.0.2+1.21.1 (extra_mod_integrations)
  • Extra Mod Integrations Core 1.0.2+1.21.1 (extra_mod_integrations_core)
  • Extreme Sound Muffler 3.49.2 (extremesoundmuffler)
  • Fabric Language Kotlin 1.13.3kotlin.2.1.21 (fabric_language_kotlin)
  • Farmer's Delight 1.2.8 (farmersdelight)
  • Fast Step Down 0.2.0 (fast_step_down)
  • Forgified Fabric API 0.115.6+2.1.1+1.21.1 (fabric_api)
  • Forgified Fabric API Base 0.4.42+d1308ded19 (fabric_api_base)
  • Forgified Fabric API Lookup API (v1) 1.6.70+c21168c319 (fabric_api_lookup_api_v1)
  • Forgified Fabric Biome API (v1) 13.0.31+1e62d33c19 (fabric_biome_api_v1)
  • Forgified Fabric Block API (v1) 1.0.22+a6e994cd19 (fabric_block_api_v1)
  • Forgified Fabric BlockRenderLayer Registration (v1) 1.1.52+b089b4bd19 (fabric_blockrenderlayer_v1)
  • Forgified Fabric BlockView API (v2) 1.0.11+e9036fd419 (fabric_block_view_api_v2)
  • Forgified Fabric Client Tags 1.1.15+e053909619 (fabric_client_tags_api_v1)
  • Forgified Fabric Command API (v2) 2.2.28+36d727be19 (fabric_command_api_v2)
  • Forgified Fabric Content Registries (v0) 8.0.18+0a0c14ff19 (fabric_content_registries_v0)
  • Forgified Fabric Convention Tags 2.1.4+7f945d5b19 (fabric_convention_tags_v1)
  • Forgified Fabric Convention Tags (v2) 2.11.0+87e5848019 (fabric_convention_tags_v2)
  • Forgified Fabric Data Attachment API (v1) 1.4.3+58235da019 (fabric_data_attachment_api_v1)
  • Forgified Fabric Data Generation API (v1) 20.2.28+2d91a6db19 (fabric_data_generation_api_v1)
  • Forgified Fabric Entity Events (v1) 1.7.0+1af6e62419 (fabric_entity_events_v1)
  • Forgified Fabric Events Interaction (v0) 0.7.13+7b71cc1619 (fabric_events_interaction_v0)
  • Forgified Fabric Game Rule API (v1) 1.0.53+36d727be19 (fabric_game_rule_api_v1)
  • Forgified Fabric Game Test API (v1) 2.0.5+29f188ce19 (fabric_gametest_api_v1)
  • Forgified Fabric Item API (v1) 11.1.1+57cdfa8219 (fabric_item_api_v1)
  • Forgified Fabric Item Group API (v1) 4.1.7+e324903319 (fabric_item_group_api_v1)
  • Forgified Fabric Key Binding API (v1) 1.0.47+62cc7ce119 (fabric_key_binding_api_v1)
  • Forgified Fabric Lifecycle Events (v1) 2.5.0+a2ee258a19 (fabric_lifecycle_events_v1)
  • Forgified Fabric Loot API (v2) 3.0.15+a3ee712d19 (fabric_loot_api_v2)
  • Forgified Fabric Loot API (v3) 1.0.3+333dfad919 (fabric_loot_api_v3)
  • Forgified Fabric Message API (v1) 6.0.13+e053909619 (fabric_message_api_v1)
  • Forgified Fabric Model Loading API (v1) 2.0.0+986ae77219 (fabric_model_loading_api_v1)
  • Forgified Fabric Networking API (v1) 4.3.0+ab6ec1d119 (fabric_networking_api_v1)
  • Forgified Fabric Object Builder API (v1) 15.2.1+cc242efd19 (fabric_object_builder_api_v1)
  • Forgified Fabric Particles (v1) 4.0.2+824f924c19 (fabric_particles_v1)
  • Forgified Fabric Recipe API (v1) 5.0.14+59440bcc19 (fabric_recipe_api_v1)
  • Forgified Fabric Registry Sync (v0) 5.2.0+867470b919 (fabric_registry_sync_v0)
  • Forgified Fabric Renderer - Indigo 1.7.0+4198af7119 (fabric_renderer_indigo)
  • Forgified Fabric Renderer API (v1) 3.4.0+9c40919e19 (fabric_renderer_api_v1)
  • Forgified Fabric Rendering (v1) 5.0.5+0d1668bc19 (fabric_rendering_v1)
  • Forgified Fabric Rendering Data Attachment (v1) 0.3.49+73761d2e19 (fabric_rendering_data_attachment_v1)
  • Forgified Fabric Rendering Fluids (v1) 3.1.6+857185bc19 (fabric_rendering_fluids_v1)
  • Forgified Fabric Resource Conditions API (v1) 4.3.0+5bdd099819 (fabric_resource_conditions_api_v1)
  • Forgified Fabric Resource Loader (v0) 1.3.1+4ea8954419 (fabric_resource_loader_v0)
  • Forgified Fabric Screen API (v1) 2.0.25+4228281319 (fabric_screen_api_v1)
  • Forgified Fabric Screen Handler API (v1) 1.3.88+8dbc56dd19 (fabric_screen_handler_api_v1)
  • Forgified Fabric Sound API (v1) 1.0.23+10b84f8419 (fabric_sound_api_v1)
  • Forgified Fabric Transfer API (v1) 5.4.2+a25cb45619 (fabric_transfer_api_v1)
  • Forgified Fabric Transitive Access Wideners (v1) 6.2.0+6c854b6f19 (fabric_transitive_access_wideners_v1)
  • FTB Chunks 2101.1.8 (ftbchunks)
  • FTB Library 2101.1.13 (ftblibrary)
  • FTB Teams 2101.1.2 (ftbteams)
  • FTB Ultimine 2101.1.3 (ftbultimine)
  • FTB Ultimine Tweaks Neo 0.1.1 (ftbultiminetweaksneo)
  • GeckoLib 4 4.7.6 (geckolib)
  • Global Packs 21.0.1 (globalpacks)
  • Glodium 1.21-2.2-neoforge (glodium)
  • GokiSkills 1.0.5-1.21 (gokiskills)
  • GregTech 7.1.0-SNAPSHOT+044f801 (gtceu)
  • GregTech Enchantable 0.18.3 (gregtechenchantable)
  • GregTech EU P2P 0.0.1 (gregtecheup2p)
  • GregTech Modern Pack Addon 0.1.0 (gtmpa)
  • GregTech Programmed Circuit Tweak 0.1.0 (gregtechprogrammedcircuittweak)
  • GuideME 21.1.13 (guideme)
  • iChunUtil 1.0.3 (ichunutil)
  • IMBlocker 5.0.3 (imblocker)
  • Immediate Advancement Screenshot 0.0.1 (immediateadvancementscreenshot)
  • Infinite Capacity Cell 0.5.0 (infcapcell)
  • Inventory Profiles Next 2.1.7 (inventoryprofilesnext)
  • Item Damage Event 0.0.6 (itemdamageevent)
  • Item Initial Age 0.0.1 (iteminitialage)
  • Item Merge Range 0.0.1 (itemmergerange)
  • Item Pickup Delay 0.0.1 (itempickupdelay)
  • Jade 15.10.2+neoforge (jade)
  • Jankson 8.0.0j1.2.3 (jankson)
  • JEI Integration Reborn 1.0.1 (jei_integration_reborn)
  • Just Enough Items 19.22.0.315 (jei)
  • Key Bindings Keeper 0.0.1 (keybindingskeeper)
  • Kotlin For Forge 5.9.0 (kotlinforforge)
  • KumaAPI 21.0.5 (kuma_api)
  • Language Reload 1.7.31.21.1 (languagereload)
  • LibGui 11.0.01.21 (libgui)
  • libIPN 6.5.0 (libipn)
  • LibNinePatch 1.2.0 (libninepatch)
  • Loaded Mods Checker 0.2.0 (loadedmodschecker)
  • LowDragLib 1.0.35.a (ldlib)
  • Luck All Bonus 0.0.1 (luckallbonus)
  • MaFgLib 0.3.6+mc1.21.1 (mafglib)
  • MaxHealthFix 21.1.4 (maxhealthfix)
  • ME Requester 1.21.1-1.2.0 (merequester)
  • MidnightLib 1.7.5 (midnightlib)
  • Minecraft 1.21.1 (minecraft)
  • MinimalismLeafDecay 0.2.0 (minimalism_leaf_decay)
  • NaNny 1.0.1 (nanny)
  • NeoForge 21.1.197 (neoforge)
  • No Repair Cost 0.0.1 (norepaircost)
  • NoCommandChatLimit 0.0.1 (nccl)
  • NonUpdate Reloaded 2.1.2 (nonupdate_reloaded)
  • Not Enough Recipe Book 0.4.2 (nerb)
  • OctoLib 0.5.0.1 (octolib)
  • Outline Through 0.0.1 (outlinethrough)
  • Overflowing Bars 21.1.1 (overflowingbars)
  • Patchouli 1.21.1-92-NEOFORGE (patchouli)
  • patternbetter 1.0.0 (patternbetter)
  • Persistent Stuff 1.2.0 (persistent_stuff)
  • Pick Up Notifier 21.1.1 (pickupnotifier)
  • Placebo 9.9.0 (placebo)
  • PrickleMC 21.1.6 (prickle)
  • Pufferfish's Attributes 0.7.3 (puffish_attributes)
  • Pufferfish's Skills 0.16.3 (puffish_skills)
  • Puzzles Lib 21.1.33 (puzzleslib)
  • Responsive Shields 2.4 (responsiveshields)
  • Saturation Plus 1.0.0-neoforge-1.21 (saturation_plus)
  • Screenshot Compression 1.1 (screenshotcompression)
  • Screenshot Organisation 1.8 (screenshot_organisation)
  • Shared Resources API 1.8.0 (shared_resources_api)
  • Simple Enchantment Toggle 0.0.1 (simpleenchantmenttoggle)
  • Simple Magnets 1.1.12+c (simplemagnets)
  • Sinytra Connector 2.0.0-beta.8+1.21.1 (connector)
  • Sophisticated Backpack AE 0.1.2 (sophisticatedbackpackae)
  • Sophisticated Backpacks 3.24.15 (sophisticatedbackpacks)
  • Sophisticated Core 1.3.52 (sophisticatedcore)
  • spark 1.10.124 (spark)
  • Spice of Life Onion 1.5.0 (solonion)
  • Spice of Life: Carrot Edition 1.16.5 (solcarrot)
  • Staaaaaaaaaaaack 1.21.1-1.7 (staaaaaaaaaaaack)
  • Stack to Nearby Chests 0.5.10 (stack_to_nearby_chests)
  • SuperMartijn642's Config Library 1.1.8 (supermartijn642configlib)
  • SuperMartijn642's Core Lib 1.1.18+a (supermartijn642corelib)
  • Tax Free Levels 1.4.7 (taxfreelevels)
  • Tooltip Auto Scale 0.0.1 (tooltipautoscale)
  • TrilevelConfig 0.4.1 (trilevel_config)
  • TriLevelConfig 1.11.1 (trilevelconfig)
  • Tweakerge 0.3.2-mc1.21.1 (tweakerge)
  • Universal Enchants 21.1.5 (universalenchants)
  • Vanilla Cookbook 2.3.2 (vanillacookbook)
  • Wandering Trader Despawn Delay 0.0.1 (wanderingtraderdespawndelay)
  • Waystones 21.1.19 (waystones)
  • Wooden Hopper 1.21.1-3.2.0.0 (woodenhopper)
  • Wooden Shears 1.21-3.2.1.1 (woodenshears)
  • Xaero's Minimap 25.2.6 (xaerominimap)
  • Xaero's World Map 1.39.9 (xaeroworldmap)
  • XaeroPlus 2.27.2 (xaeroplus)
  • Xp Orb No Cooldown 0.0.1 (xporbnocooldown)
  • YetAnotherConfigLib 3.6.6+1.21.1-neoforge (yet_another_config_lib_v3)

Expected Behavior

EnergyContainerList.hasPrimeFactorGreaterThanTwo should return.

private static boolean hasPrimeFactorGreaterThanTwo(long l) {

Actual Behavior

Sometimes EnergyContainerList.hasPrimeFactorGreaterThanTwo will never return.

Steps to Reproduce

It's hard to reproduce in a normal save, but in my save (with my modpack) I can reproduce it every time. I think passing a large number that doesn't have any prime factor in int range to EnergyContainerList.hasPrimeFactorGreaterThanTwo can also reproduce it.

Additional Information

Because it is a endless loop, it doesn't crash or report any error in log.
I even made a mod to detect the loop and print stacktraces of all threads, that's why I found the actual reason.
Here is the client watchdog mod:
ClientSimpleWatchdog-1.21.1-0.3.4.jar.zip
I have spent dozens of hours for this bug๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ญ

I finally fixed (?) it by a mixin (at least I can normally play my save currently):

@Mixin(value = EnergyContainerList.class, remap = false)
abstract class MEnergyContainerList {
    /**
     @author Phoupraw
     @reason try fix
     */
    @Overwrite
    private static boolean hasPrimeFactorGreaterThanTwo(long l) {
        long i = 2;
        final long max = (long) Math.ceil(Math.sqrt(l));
        while (i <= max) {
            if (l % i == 0) {
                if (i > 2) return true;
                l /= i;
            } else {
                i++;
            }
        }
        return false;
    }
}
commented

Can't this be expressed as 'is this number greater than 1 and not a power of 2'?
In that case, why not use for(int i = 1; i < 63; i++) { if(x == (1L << i)) return true; if(x < (1L << i)) return false; }; return false;?

commented

Oh wait, even better: x > 1 && x & (x-1) != 0

commented

Even better would be to use one of the methods in java.lang.Long - like bitCount or highestOneBit which makes the code easier to read.