Skip to content

Patches for various crashes#781

Merged
ACGaming merged 4 commits into
ACGaming:mainfrom
RecursivePineapple:fix-misc-crashes
Jan 1, 2026
Merged

Patches for various crashes#781
ACGaming merged 4 commits into
ACGaming:mainfrom
RecursivePineapple:fix-misc-crashes

Conversation

@RecursivePineapple

Copy link
Copy Markdown
Contributor

This PR has a few patches for some frequent crashes in meatballcraft. I didn't put too much effort into root causing them, I just mitigated the crashes. I made sure my changes didn't break anything, but most of these mixins just no-op the code instead of fixing whatever's causing the issue.

Since these crashes are so sporadic, I couldn't reproduce them on-demand in my dev env. The only one I could test was the abyssalcraft crash, since that happens when you try to make an altar with the wrong blocks in the wrong dimension. I verified the others by enabling -Dmixin.debug=true and making sure the dumped code looked correct. Since the mixins are so simple I didn't think it was necessary to restart my game dozens of times to verify they worked properly.

I just pasted the exception stack traces in the javadoc for each mixin because I wasn't sure what the best way to document them would be. The reason for the crashes are fairly self-evident when you look at the target code.

The only tricky one is UTItemHandlerIteratorMixin. As far as I can tell, it's caused by the ItemHandler's size changing while the iterator is iterating over it. I don't know what machine is causing this issue because that info isn't in my logs, so I just patched the problem by returning empty stacks and cancelled the throw NoSuchElementException.

@jchung01

Copy link
Copy Markdown
Contributor

Mentioned in Discord, but the Abyssalcraft tweak is not necessary, I reported it to Shinoow/AbyssalCraft#553 and it is fixed in 1.11.3/2.0.0-BETA-6.

@WaitingIdly WaitingIdly left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the documentation of the mixins, i would suggest doing it in this format:

/**
 * @author RecursivePineapple
 * @reason ensure index is not out of bounds
 */
@Inject(...)

@Config.RequiresMcRestart
@Config.Name("Mitigate Storage Bus Crashes")
@Config.Comment("Mitigates crashes caused by misbehaving IItemHandlers.")
public boolean uteItemHandlerCrash = true;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ute?

Suggested change
public boolean uteItemHandlerCrash = true;
public boolean utItemHandlerCrash = true;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo, fixed

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is currently always enabled - added if c.isModPresent("abyssalcraft"). if it is to be added, split it out into its own config.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like I forgot to split that off into its own mixin set, thanks for catching that

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just removed this mixin entirely since the issue is properly fixed.

/// at net.minecraft.util.Util.runTask(SourceFile:529)
/// ... 5 more
@Inject(method = "execute", at = @At(value = "INVOKE", target = "Lmcjty/xnet/blocks/controller/TileEntityController;createChannel(ILjava/lang/String;)V"), cancellable = true)
private void ut$fixCreateChannel(EntityPlayerMP playerMP, String command, TypedMap params, CallbackInfoReturnable<Boolean> cir, @Local(type = int.class) int index) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is type = int.class actually needed here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure but it's what I always do and it works fine. I don't see a reason to not add specificity.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesnt do anything in this context
image

/// at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526)
/// at java.lang.Thread.run(Thread.java:1474)
@Inject(method = "next()Lappeng/util/inv/ItemSlot;", at = @At(value = "NEW", target = "()Ljava/util/NoSuchElementException;"), cancellable = true)
private void ut$preventNSEE(CallbackInfoReturnable<ItemSlot> cir) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think throwing an NoSuchElementException is the correct behavior here, and the issue lies with whatever is having variable item slots between calls. to debug the cause, i would suggest doing @WrapMethod with a try { original() } catch for this in PartStorageBus#tickingRequest and logging the position it happened to.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I'd usually agree with you, this crash is very hard to reproduce and I'm not even sure what the actual cause is. Like I said, I can't be bothered to restart my game a few dozen times to test it. This is absolutely a hack but there's no reason that a misbehaving IItemHandler should crash the game.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to add this: an IItemHandler reporting more slots than it has is absolutely a bug, but there's no logic error from pretending those slots exist but aren't interactable. This iterator is just used for determining what items an IItemHandler contains, so at most you're going to get false-negatives (items in storage that aren't reported to AE). Assuming the IItemHandler eventually corrects itself, this isn't even permanent because storage busses poll their attached inventories constantly.

@RecursivePineapple

Copy link
Copy Markdown
Contributor Author

for the documentation of the mixins, i would suggest doing it in this format:

I added some info to the AE2 mixin, but most of these bugs are trivial index errors. I don't like adding comments where they aren't necessary. I added the stacktraces to the mixins so that the mixins can be removed if these bugs are ever fixed properly. I doubt people will look at the blame to find this PR, so I didn't want to add them here.

@ACGaming

ACGaming commented Jan 1, 2026

Copy link
Copy Markdown
Owner

Appreciated, but I'm going to keep the AE2 tweak as opt-in for now.

@ACGaming ACGaming merged commit 1919944 into ACGaming:main Jan 1, 2026
1 check passed
ACGaming added a commit that referenced this pull request Jan 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants