Jump to content

[1.7.10] [SOLVED] Coremod issue: VerifyError: Expecting a stackmap frame...


Recommended Posts

Posted

Good day.

I'm having issues with my coremod:

I'm trying to patch Chunk.getBlockMetadata (don't ask me why, it's a long story). And i'm having problems with it:

When trying to use this transformer on method:

public class InvisiZonesTransformer implements IClassTransformer{

public static Logger logger = LogManager.getLogger("IZ Core");

@Override
public byte[] transform(String name, String transformedName, byte[] bytes) {
	if(name.equals(InvisiZonesTranslator.getMapedClassName("world.chunk.Chunk"))){
		logger.info("##################################################");
		logger.info("Patching Chunk");
		byte[] b = patchChunk(name, bytes);
		logger.info("Patching Chunk Completed");
		logger.info("##################################################");
		return b;
	}
	return bytes;
}

private byte[] patchChunk(String name, byte[] bytes) {
	String getBlock = InvisiZonesTranslator.getMapedMethodName("Chunk", "func_150810_a", "getBlock");
	String getBlockDesc = InvisiZonesTranslator.getMapedMethodDesc("Chunk", "func_150810_a", "(III)Lnet/minecraft/block/Block;");
	String getBlockMetadata = InvisiZonesTranslator.getMapedMethodName("Chunk", "func_76628_c", "getBlockMetadata");
	String getBlockMetadataDesc = InvisiZonesTranslator.getMapedMethodDesc("Chunk", "func_76628_c", "(III)I");
	String getTileEntityUnsafe = "getTileEntityUnsafe";
	String func_150806_e = InvisiZonesTranslator.getMapedMethodName("Chunk", "func_150806_e", "func_150806_e");
	String func_150806_eDesc = InvisiZonesTranslator.getMapedMethodDesc("Chunk", "func_150806_e", "(III)Lnet/minecraft/tileentity/TileEntity;");

	ClassNode classNode = new ClassNode();
	ClassReader classReader = new ClassReader(bytes);
	classReader.accept(classNode, 0);

	for(MethodNode method : classNode.methods){
		if(method.name.equals(getBlockMetadata) && method.desc.equals(getBlockMetadataDesc)){
			try{
				logger.info("**************************************************");
				logger.info("Patching getBlockMetadata");

				LabelNode skipTo = new LabelNode();

				InsnList list = new InsnList();
				list.add(new LabelNode());
				list.add(new VarInsnNode(Opcodes.ALOAD, 0));
				list.add(new VarInsnNode(Opcodes.ILOAD, 1));
				list.add(new VarInsnNode(Opcodes.ILOAD, 2));
				list.add(new VarInsnNode(Opcodes.ILOAD, 3));
				list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "code.elix_x.coremods.invisizones.core.InvisiZoneHooks".replace(".", "/"), "doGetBlockMetadataInsideChunk", "(L" + InvisiZonesTranslator.getMapedClassName("world.chunk.Chunk").replace(".", "/") + ";III)Z", false));
				list.add(new JumpInsnNode(Opcodes.IFNE, skipTo));
				list.add(new LabelNode());
				list.add(new VarInsnNode(Opcodes.ALOAD, 0));
				list.add(new VarInsnNode(Opcodes.ILOAD, 1));
				list.add(new VarInsnNode(Opcodes.ILOAD, 2));
				list.add(new VarInsnNode(Opcodes.ILOAD, 3));
				list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "code.elix_x.coremods.invisizones.core.InvisiZoneHooks".replace(".", "/"), "getBlockMetadataInsideChunk", "(L" + InvisiZonesTranslator.getMapedClassName("world.chunk.Chunk").replace(".", "/") + ";III)I", false));
				list.add(new InsnNode(Opcodes.ARETURN));
				list.add(skipTo);
				method.instructions.insert(list);

				logger.info("Patching getBlockMetadata Completed");
				logger.info("**************************************************");
			}catch(Exception e){
				logger.info("Patching getBlockMetadata Failed With Exception:");
				e.printStackTrace();
				logger.info("**************************************************");
			}
		}
	}

	ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
	classNode.accept(writer);
	return writer.toByteArray();
}

}

Gives me this log when patching:

[13:46:46] [server thread/INFO] [iZ Core]: ##################################################
[13:46:46] [server thread/INFO] [iZ Core]: Patching Chunk
[13:46:46] [server thread/INFO] [iZ Core]: **************************************************
[13:46:46] [server thread/INFO] [iZ Core]: Patching getBlockMetadata
[13:46:46] [server thread/INFO] [iZ Core]: Patching getBlockMetadata Completed
[13:46:46] [server thread/INFO] [iZ Core]: **************************************************
[13:46:46] [server thread/INFO] [iZ Core]: Patching Chunk Completed
[13:46:46] [server thread/INFO] [iZ Core]: ##################################################
[13:46:46] [server thread/ERROR]: Encountered an unexpected exception
java.lang.VerifyError: Expecting a stackmap frame at branch target 18
Exception Details:
  Location:
    net/minecraft/world/chunk/Chunk.getBlock(III)Lnet/minecraft/block/Block; @7: ifne
  Reason:
    Expected stackmap frame at this location.
  Bytecode:
    0x0000000: 2a1b 1c1d b801 2f9a 000b 2a1b 1c1d b801
    0x0000010: 33b0 b200 a33a 041c 077a 2ab4 0044 bea2
    0x0000020: 0055 2ab4 0044 1c07 7a32 3a05 1905 c600
    0x0000030: 4619 051b 1c10 0f7e 1db6 0136 3a04 a700
    0x0000040: 363a 0619 0613 0138 b801 3e3a 0719 0713
    0x0000050: 0140 b601 443a 0819 0813 0146 bb00 0759
    0x0000060: 2a1b 1c1d b701 49b6 014f bb01 5159 1907
    0x0000070: b701 54bf 1904 b0                      
  Exception Handler Table:
    bci [49, 62] => handler: 65
  Stackmap Table:
    full_frame(@65,{Object[#2],Integer,Integer,Integer,Object[#129],Object[#66]},{Object[#297]})
    chop_frame(@116,1)

at net.minecraft.world.gen.ChunkProviderServer.<init>(ChunkProviderServer.java:57) ~[ChunkProviderServer.class:?]
at net.minecraft.world.WorldServer.createChunkProvider(WorldServer.java:693) ~[WorldServer.class:?]
at net.minecraft.world.World.<init>(World.java:281) ~[World.class:?]
at net.minecraft.world.WorldServer.<init>(WorldServer.java:102) ~[WorldServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:63) ~[integratedServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:96) ~[integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:445) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?]
[13:46:46] [server thread/ERROR]: This crash report has been saved to: C:\my\mcmodding\mods\Invisi-Zones\eclipse\.\crash-reports\crash-2015-08-14_13.46.46-server.txt
[13:46:46] [server thread/INFO] [FML]: Applying holder lookups
[13:46:46] [server thread/INFO] [FML]: Holder lookups applied
[13:46:47] [server thread/INFO] [invisiZonesManager]: Clearing zones on: CLIENT
[13:46:47] [server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STARTING and forced into state SERVER_STOPPED. Errors may have been discarded.
[13:46:47] [Client thread/INFO] [sTDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: ---- Minecraft Crash Report ----
// Don't do that.

Time: 14.08.15 13:46
Description: Exception in server tick loop

java.lang.VerifyError: Expecting a stackmap frame at branch target 18
Exception Details:
  Location:
    net/minecraft/world/chunk/Chunk.getBlock(III)Lnet/minecraft/block/Block; @7: ifne
  Reason:
    Expected stackmap frame at this location.
  Bytecode:
    0x0000000: 2a1b 1c1d b801 2f9a 000b 2a1b 1c1d b801
    0x0000010: 33b0 b200 a33a 041c 077a 2ab4 0044 bea2
    0x0000020: 0055 2ab4 0044 1c07 7a32 3a05 1905 c600
    0x0000030: 4619 051b 1c10 0f7e 1db6 0136 3a04 a700
    0x0000040: 363a 0619 0613 0138 b801 3e3a 0719 0713
    0x0000050: 0140 b601 443a 0819 0813 0146 bb00 0759
    0x0000060: 2a1b 1c1d b701 49b6 014f bb01 5159 1907
    0x0000070: b701 54bf 1904 b0                      
  Exception Handler Table:
    bci [49, 62] => handler: 65
  Stackmap Table:
    full_frame(@65,{Object[#2],Integer,Integer,Integer,Object[#129],Object[#66]},{Object[#297]})
    chop_frame(@116,1)

at net.minecraft.world.gen.ChunkProviderServer.<init>(ChunkProviderServer.java:57)
at net.minecraft.world.WorldServer.createChunkProvider(WorldServer.java:693)
at net.minecraft.world.World.<init>(World.java:281)
at net.minecraft.world.WorldServer.<init>(WorldServer.java:102)
at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:63)
at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:96)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:445)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- System Details --
Details:
Minecraft Version: 1.7.10
Operating System: Windows 7 (amd64) version 6.1
Java Version: 1.8.0_25, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 896957152 bytes (855 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1492 5 mods loaded, 5 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCHIJAA	mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) 
UCHIJAA	FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1492-1.7.10.jar) 
UCHIJAA	Forge{10.13.4.1492} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1492-1.7.10.jar) 
UCHIJAA	excore{1.0} [EXCore] (bin) 
UCHIJAA	invisizones{1.0} [invisi Zones] (bin) 
GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.
Profiler Position: N/A (disabled)
Player Count: 0 / 8; []
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fml,forge'
[13:46:47] [Client thread/INFO] [sTDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:393]: #@!@# Game crashed! Crash report saved to: #@!@# .\crash-reports\crash-2015-08-14_13.46.46-server.txt
AL lib: (EE) alc_cleanup: 1 device not closed
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
JDWP exit error JVMTI_ERROR_WRONG_PHASE(112): cannot get thread local storage [threadControl.c:195]

And the thing is taht:

1) It's expecting stack map frame in the middle of actions

2) I have never met those things (errors), although i succesfully coded 4 coremods, they work and never asked for this.

3) I have no idea what and why exactly should i do with it in middle of actions.

 

Yes, i know that it's coremod and i'm kinda on my own, but... Never met it, never dealt with it, never solved it...

 

Thanks for help!

If you have any questions - just ask!

 

Posted

Stackmap frames are a huge pain in the butt.

You can try and work around it by using the COMPUTE_FRAMES flag instead of just COMPUTE_MAXS, but this is not guaranteed to work (why? Because unlike javac (the java compiler) ASM does not have all classes available to it so it can't reliable perform this task).

Welp, this didn't work (because exactly what you) (i'm sure that nobody needs that new crash, but whatever) :

java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    net/minecraft/world/chunk/Chunk.getBlockMetadata(III)I @17: areturn
  Reason:
    Type integer (current frame, stack[0]) is not assignable to reference type
  Current Frame:
    bci: @17
    flags: { }
    locals: { 'net/minecraft/world/chunk/Chunk', integer, integer, integer }
    stack: { integer }
  Bytecode:
    0x0000000: 2a1b 1c1d b801 619a 000b 2a1b 1c1d b801
    0x0000010: 65b0 1c07 7a2a b400 44be a100 0503 ac2a
    0x0000020: b400 441c 077a 323a 0419 04c6 0011 1904
    0x0000030: 1b1c 100f 7e1d b601 68a7 0004 03ac     
  Stackmap Table:
    same_frame(@18)
    same_frame(@31)
    append_frame(@60,Object[#66])
    same_locals_1_stack_item_frame(@61,Integer)

Welp... I'll have to deal with these stackmap frames myself...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.