Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random VerifyError for Kotlin jar #75

Open
amadeusmz opened this issue Dec 31, 2024 · 0 comments
Open

Random VerifyError for Kotlin jar #75

amadeusmz opened this issue Dec 31, 2024 · 0 comments

Comments

@amadeusmz
Copy link

I've tried obfuscating a Kotlin Minecraft plugin. The VerifyError occurs randomly on methods or classes after obfuscation, requiring multiple attempts to avoid the issue, but some methods or classes might remain unchecked.

I'm not sure if it because that my plugin is written in Kotlin.

The stacktrace of the obfuscated jar
> pluginmanager reload DotMan
[00:07:50 INFO]: [DotMan] Loading server plugin DotMan v1.8-premium
[00:07:50 INFO]: [DotMan] Enabling DotMan v1.8-premium
[00:07:50 INFO]: [DotMan] Floodgate hook enabled
[00:07:50 INFO]: [DotMan] Thời gian hiện tại là: 01/01/2025 00:07
[00:07:50 INFO]: [DotMan] Múi giờ hệ thống: Asia/Ho_Chi_Minh
[00:07:50 INFO]: [DotMan] Connecting to the database (MariaDB)...
[00:07:50 INFO]: [net.minevn.libs.hikari.HikariDataSource] HikariPool-3 - Starting...
[00:07:50 INFO]: [net.minevn.libs.hikari.HikariDataSource] HikariPool-3 - Start completed.
[00:07:50 INFO]: [DotMan] Connected to the database (MariaDB)
[00:07:50 INFO]: [DotMan] Current schema version: 5
[00:07:50 INFO]: [DotMan] The schema is up to date.
[00:07:50 ERROR]: Error occurred while enabling DotMan v1.8-premium (Is it up to date?)
java.lang.VerifyError: Inconsistent stackmap frames at branch target 294
Exception Details:
  Location:
    net/minevn/dotman/config/g$a.<init>(Ljava/lang/String;Ljava/lang/String;Ljava/util/Date;Ljava/util/Date;ILkotlin/jvm/internal/DefaultConstructorMarker;I)V @294: new
  Reason:
    Current frame's flags are not assignable to stack map frame's.
  Current Frame:
    bci: @240
    flags: { flagThisUninit }
    locals: { uninitializedThis, 'java/lang/String', 'java/lang/String', 'java/util/Date', 'java/util/Date', integer, 'kotlin/jvm/internal/DefaultConstructorMarker', integer, integer, integer, top, top, top, top, integer, top, top, top, top, top, top, top, top, top, top, top, integer }
    stack: { integer }
  Stackmap Frame:
    bci: @294
    flags: { }
    locals: { top, 'java/lang/String', 'java/lang/String', 'java/util/Date', 'java/util/Date', integer, 'kotlin/jvm/internal/DefaultConstructorMarker', integer, integer, integer, top, top, top, top, integer, top, top, top, top, top, top, top, top, top, top, top, integer }
    stack: { }
  Bytecode:
    0000000: 1261 1262 8236 1a15 0536 0807 3609 1508
    0000010: 1509 7e36 0e15 0e99 00d4 1263 1264 8236
    0000020: 1abb 0066 3a0f 0937 0a19 0f16 0ab7 0069
    0000030: 190f 4e12 6a12 6b82 361a 1505 3610 1008
    0000040: 3614 1510 1514 7e36 1115 1199 00e3 126c
    0000050: 126d 8236 1abb 0066 3a12 0a37 1619 1216
    0000060: 16b7 0069 1912 3a04 126e 126f 8236 1a2a
    0000070: 3a13 2b3a 152c 3a18 2d3a 0c19 043a 0d19
    0000080: 1319 1519 1819 0c19 0d12 70b7 0072 151a
    0000090: 1273 b800 5536 1a12 7412 7512 46b8 004c
    00000a0: 8282 361a 2a12 2fb2 004e 82b5 0050 151a
    00000b0: b800 7bab 0000 0073 0000 0004 02a6 0c8e
    00000c0: 0000 0029 63b8 ec00 0000 0073 6cc5 294d
    00000d0: ffff fffb 7fd7 8e74 0000 0030 127c 151a
    00000e0: 8236 1a12 7d15 1a82 361a b115 1ab8 007b
    00000f0: ab00 0000 0000 0036 0000 0004 0126 390e
    0000100: 0000 002c 38dc c3c5 ffff fffb 43f1 2578
    0000110: 0000 0036 5451 3536 ffff ff4a 127e 151a
    0000120: 8236 1aa7 ff17 bb00 8059 b700 81bf 1282
    0000130: 151a 8236 1aa7 ff3a                    
  Stackmap Table:
    full_frame(@58,{UninitializedThis,Object[#132],Object[#132],Object[#102],Object[#102],Integer,Object[#134],Integer,Integer,Integer,Top,Top,Top,Top,Integer,Top,Top,Top,Top,Top,Top,Top,Top,Top,Top,Top,Integer},{})
    full_frame(@111,{UninitializedThis,Object[#132],Object[#132],Object[#102],Object[#102],Integer,Object[#134],Integer,Integer,Integer,Top,Top,Top,Top,Integer,Top,Integer,Integer,Top,Top,Integer,Top,Top,Top,Top,Top,Integer},{})
    full_frame(@174,{Object[#2],Object[#132],Object[#132],Object[#102],Object[#102],Integer,Object[#134],Integer,Integer,Integer,Top,Top,Object[#102],Object[#102],Integer,Top,Integer,Integer,Top,Object[#2],Integer,Object[#132],Top,Top,Object[#132],Top,Integer},{})
    same_frame(@220)
    same_frame(@227)
    full_frame(@235,{UninitializedThis,Object[#132],Object[#132],Object[#102],Object[#102],Integer,Object[#134],Integer,Integer,Integer,Top,Top,Top,Top,Integer,Top,Top,Top,Top,Top,Top,Top,Top,Top,Top,Top,Integer},{})
    same_frame(@284)
    full_frame(@294,{Top,Object[#132],Object[#132],Object[#102],Object[#102],Integer,Object[#134],Integer,Integer,Integer,Top,Top,Top,Top,Integer,Top,Top,Top,Top,Top,Top,Top,Top,Top,Top,Top,Integer},{})
    full_frame(@302,{UninitializedThis,Object[#132],Object[#132],Object[#102],Object[#102],Integer,Object[#134],Integer,Integer,Integer,Top,Top,Top,Top,Integer,Top,Integer,Integer,Top,Top,Integer,Top,Top,Top,Top,Top,Integer},{})

        at net.minevn.dotman.config.g.<init>(TimeFrame.kt) ~[DotMan-obf.jar-out.jar:?]
        at net.minevn.dotman.DotMan.p(DotMan.kt) ~[DotMan-obf.jar-out.jar:?]
        at net.minevn.dotman.DotMan.onEnable(DotMan.kt) ~[DotMan-obf.jar-out.jar:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:287) ~[purpur-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:188) ~[purpur-1.20.4.jar:git-Purpur-2153]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:104) ~[purpur-1.20.4.jar:git-Purpur-2153]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:507) ~[purpur-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at net.lenni0451.spm.utils.PluginUtils.enablePlugin(PluginUtils.java:137) ~[PluginManager.jar:?]
        at net.lenni0451.spm.utils.PluginUtils.loadPlugin(PluginUtils.java:274) ~[PluginManager.jar:?]
        at net.lenni0451.spm.utils.PluginUtils.loadPlugin(PluginUtils.java:219) ~[PluginManager.jar:?]
        at net.lenni0451.spm.commands.subs.Reload_Sub.execute(Reload_Sub.java:38) ~[PluginManager.jar:?]
        at net.lenni0451.spm.commands.PluginManager_Command.lambda$onCommand$0(PluginManager_Command.java:94) ~[PluginManager.jar:?]
        at net.lenni0451.spm.commands.PluginManager_Command.onCommand(PluginManager_Command.java:110) ~[PluginManager.jar:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[purpur-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:168) ~[purpur-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_20_R3.CraftServer.dispatchCommand(CraftServer.java:1013) ~[purpur-1.20.4.jar:git-Purpur-2153]
        at org.bukkit.craftbukkit.v1_20_R3.CraftServer.dispatchServerCommand(CraftServer.java:998) ~[purpur-1.20.4.jar:git-Purpur-2153]
        at net.minecraft.server.dedicated.DedicatedServer.handleConsoleInputs(DedicatedServer.java:541) ~[purpur-1.20.4.jar:git-Purpur-2153]
        at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:488) ~[purpur-1.20.4.jar:git-Purpur-2153]
        at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1548) ~[purpur-1.20.4.jar:git-Purpur-2153]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1236) ~[purpur-1.20.4.jar:git-Purpur-2153]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:323) ~[purpur-1.20.4.jar:git-Purpur-2153]
        at java.lang.Thread.run(Thread.java:1583) ~[?:?]
[00:07:50 INFO]: [DotMan] Disabling DotMan v1.8-premium
The obfuscation log

(The UnsatisfiedLinkError stacktrace is unrelated (I guess) and is reported in another issue)

root@DESKTOP-324N59P:~# java -Xmx4G -jar lt/skidfuscator.jar obfuscate lt/jars/DotMan-obf.jar -li=dotman-lib

  /$$$$$$  /$$       /$$       /$$  /$$$$$$                                           /$$
 /$$__  $$| $$      |__/      | $$ /$$__  $$                                         | $$
| $$  \__/| $$   /$$ /$$  /$$$$$$$| $$  \__//$$   /$$  /$$$$$$$  /$$$$$$$  /$$$$$$  /$$$$$$    /$$$$$$   /$$$$$$
|  $$$$$$ | $$  /$$/| $$ /$$__  $$| $$$$   | $$  | $$ /$$_____/ /$$_____/ |____  $$|_  $$_/   /$$__  $$ /$$__  $$
 \____  $$| $$$$$$/ | $$| $$  | $$| $$_/   | $$  | $$|  $$$$$$ | $$        /$$$$$$$  | $$    | $$  \ $$| $$  \__/
 /$$  \ $$| $$_  $$ | $$| $$  | $$| $$     | $$  | $$ \____  $$| $$       /$$__  $$  | $$ /$$| $$  | $$| $$
|  $$$$$$/| $$ \  $$| $$|  $$$$$$$| $$     |  $$$$$$/ /$$$$$$$/|  $$$$$$$|  $$$$$$$  |  $$$$/|  $$$$$$/| $$
 \______/ |__/  \__/|__/ \_______/|__/      \______/ |_______/  \_______/ \_______/   \___/   \______/ |__/

                               ┌───────────────────────────────────────────┐
                               │         Processors:   16 cores            │
                               │     Current Memory:   192mb               │
                               │         Max Memory:   4295mb              │
                               └───────────────────────────────────────────┘

                      Author: Ghast     Version: 2.0.11     Today: Dec 31, 2024, 11:50:07 PM
✔  Imported configuration
✔  Imported 61 exclusions
✔  Imported 128 classes from /root/lt/jars/DotMan-obf.jar
✔  Imported the JVM JDK (> 9) [x69]
✔  Verified classpath for 128 classes
✔  Resolved context analysis
✔  Cached over 150 classes!
✔  Established inheritance for 128 nodes
✔  Resolved invocation path for 128 nodes
✔  Loaded 10 transformers!
✔  Hot-loaded 128 classes

┌───────────────────────────[ Transform ]───────────────────────────┐

java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at dev.skidfuscator.obfuscator.event.EventBus$EventListener.callUnsafe(EventBus.java:203)
        at dev.skidfuscator.obfuscator.event.EventBus.call(EventBus.java:91)
        at dev.skidfuscator.obfuscator.Skidfuscator.run(Skidfuscator.java:886)
        at dev.skidfuscator.obfuscator.Skidfuscator.init(Skidfuscator.java:1047)
        at dev.skidfuscator.obfuscator.Skidfuscator.run(Skidfuscator.java:309)
        at dev.skidfuscator.obfuscator.command.ObfuscateCommand.call(ObfuscateCommand.java:156)
        at dev.skidfuscator.obfuscator.command.ObfuscateCommand.call(ObfuscateCommand.java:23)
        at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
        at picocli.CommandLine.access$1300(CommandLine.java:145)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2358)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2352)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2314)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2316)
        at picocli.CommandLine.execute(CommandLine.java:2078)
        at dev.skidfuscator.obfuscator.SkidfuscatorMain.main(SkidfuscatorMain.java:79)
Caused by: java.lang.IllegalStateException: VM initialization failed
        at dev.xdark.ssvm.VirtualMachine.init(VirtualMachine.java:611)
        at dev.xdark.ssvm.VirtualMachine.tryInitialize(VirtualMachine.java:619)
        at dev.xdark.ssvm.VirtualMachine.bootstrap(VirtualMachine.java:265)
        at dev.skidfuscator.obfuscator.number.pure.VmHashTransformer.init(VmHashTransformer.java:244)
        at dev.skidfuscator.obfuscator.number.pure.VmHashTransformer.<init>(VmHashTransformer.java:47)
        at dev.skidfuscator.obfuscator.transform.impl.pure.PureHashTransformer.handle(PureHashTransformer.java:17)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        ... 17 more
Caused by: dev.xdark.ssvm.execution.VMException: java/lang/UnsatisfiedLinkError: java/lang/Class.registerNatives()V
        at dev.xdark.ssvm.operation.DefaultExceptionOperations.throwException(DefaultExceptionOperations.java:62)
        at dev.xdark.ssvm.operation.ExceptionOperations.throwException(ExceptionOperations.java:79)
        at dev.xdark.ssvm.operation.ExceptionOperations.throwException(ExceptionOperations.java:89)
        at dev.xdark.ssvm.operation.VMOperations.throwException(VMOperations.java:42)
        at dev.xdark.ssvm.api.SimpleVMInterface.handleLinkageError0(SimpleVMInterface.java:161)
        at dev.xdark.ssvm.api.SimpleVMInterface.handleLinkageError(SimpleVMInterface.java:146)
        at dev.xdark.ssvm.execution.InterpretedInvoker.intercept(InterpretedInvoker.java:22)
        at dev.xdark.ssvm.execution.SimpleExecutionEngine.execute(SimpleExecutionEngine.java:58)
        at dev.xdark.ssvm.operation.DefaultInvocationOperations.invoke(DefaultInvocationOperations.java:30)
        at dev.xdark.ssvm.operation.VMOperations.invoke(VMOperations.java:46)
        at dev.xdark.ssvm.execution.rewrite.method.AbstractVMCallProcessor.execute(AbstractVMCallProcessor.java:35)
        at dev.xdark.ssvm.execution.rewrite.method.AbstractVMCallProcessor.execute(AbstractVMCallProcessor.java:18)
        at dev.xdark.ssvm.execution.Interpreter.execute(Interpreter.java:57)
        at dev.xdark.ssvm.execution.InterpretedInvoker.intercept(InterpretedInvoker.java:36)
        at dev.xdark.ssvm.execution.SimpleExecutionEngine.execute(SimpleExecutionEngine.java:58)
        at dev.xdark.ssvm.operation.DefaultInvocationOperations.invoke(DefaultInvocationOperations.java:30)
        at dev.xdark.ssvm.operation.DefaultInvocationOperations.invokeVoid(DefaultInvocationOperations.java:36)
        at dev.xdark.ssvm.operation.VMOperations.invokeVoid(VMOperations.java:46)
        at dev.xdark.ssvm.operation.DefaultClassOperations.initialize(DefaultClassOperations.java:226)
        at dev.xdark.ssvm.operation.VMOperations.initialize(VMOperations.java:56)
        at dev.xdark.ssvm.execution.rewrite.method.AbstractVMCallProcessor.execute(AbstractVMCallProcessor.java:28)
        at dev.xdark.ssvm.execution.rewrite.method.AbstractVMCallProcessor.execute(AbstractVMCallProcessor.java:18)
        at dev.xdark.ssvm.execution.Interpreter.execute(Interpreter.java:57)
        at dev.xdark.ssvm.execution.InterpretedInvoker.intercept(InterpretedInvoker.java:36)
        at dev.xdark.ssvm.execution.SimpleExecutionEngine.execute(SimpleExecutionEngine.java:58)
        at dev.xdark.ssvm.operation.DefaultInvocationOperations.invoke(DefaultInvocationOperations.java:30)
        at dev.xdark.ssvm.operation.DefaultInvocationOperations.invokeVoid(DefaultInvocationOperations.java:36)
        at dev.xdark.ssvm.operation.VMOperations.invokeVoid(VMOperations.java:46)
        at dev.xdark.ssvm.operation.DefaultClassOperations.initialize(DefaultClassOperations.java:226)
        at dev.xdark.ssvm.operation.DefaultClassOperations.initialize(DefaultClassOperations.java:219)
        at dev.xdark.ssvm.operation.DefaultClassOperations.initialize(DefaultClassOperations.java:219)
        at dev.xdark.ssvm.operation.DefaultClassOperations.initialize(DefaultClassOperations.java:219)
        at dev.xdark.ssvm.operation.DefaultClassOperations.initialize(DefaultClassOperations.java:219)
        at dev.xdark.ssvm.operation.VMOperations.initialize(VMOperations.java:56)
        at dev.xdark.ssvm.operation.DefaultExceptionOperations.newException(DefaultExceptionOperations.java:68)
        at dev.xdark.ssvm.operation.ExceptionOperations.throwException(ExceptionOperations.java:79)
        at dev.xdark.ssvm.operation.ExceptionOperations.throwException(ExceptionOperations.java:89)
        at dev.xdark.ssvm.operation.VMOperations.throwException(VMOperations.java:42)
        at dev.xdark.ssvm.LinkHelper.checkField(LinkHelper.java:41)
        at dev.xdark.ssvm.LinkResolver.resolveVirtualField(LinkResolver.java:57)
        at dev.xdark.ssvm.operation.DefaultFieldOperations.getFieldOffsetForInstance(DefaultFieldOperations.java:354)
        at dev.xdark.ssvm.operation.DefaultFieldOperations.putInt(DefaultFieldOperations.java:58)
        at dev.xdark.ssvm.operation.DefaultFieldOperations.putInt(DefaultFieldOperations.java:64)
        at dev.xdark.ssvm.operation.VMOperations.putInt(VMOperations.java:44)
        at dev.xdark.ssvm.thread.virtual.VirtualThreadManager.attachCurrentThread(VirtualThreadManager.java:157)
        at dev.xdark.ssvm.VirtualMachine.init(VirtualMachine.java:580)
        ... 23 more
Caused by: java/lang/UnsatisfiedLinkError: java/lang/Class.registerNatives()V
        at dev.xdark.ssvm.operation.DefaultExceptionOperations.toJavaException(DefaultExceptionOperations.java:88)
        at dev.xdark.ssvm.operation.VMOperations.toJavaException(VMOperations.java:42)
        at dev.xdark.ssvm.execution.VMException.<init>(VMException.java:19)
│  ✔  Running phase [Init] on 128 classes                           │
│  ✔  Running phase [Init] on 937 method groups                     │
│  ✔  Running phase [Init] on 1121 methods                          │
│  Found 0 issues |  Modified 0                                     │
│───────────────────────────────────────────────────────────────────│
│  ✔  Running phase [Pre-Transform] on 128 classes                  │
│  ✔  Running phase [Pre-Transform] on 937 method groups            │
│  ✔  Running phase [Pre-Transform] on 1121 methods                 │
│  Found 0 issues |  Modified 0                                     │
│───────────────────────────────────────────────────────────────────│
│  ✔  Running phase [Transform] on 128 classes                      │
│  ✔  Running phase [Transform] on 937 method groups                │
│  ✔  Running phase [Transform] on 1121 methods                     │
│  Found 0 issues |  Modified 0                                     │
│───────────────────────────────────────────────────────────────────│
│  ✔  Running phase [Post-Transform] on 128 classes                 │
│  ✔  Running phase [Post-Transform] on 937 method groups           │
│  ✔  Running phase [Post-Transform] on 1121 methods                │
│  Found 0 issues |  Modified 0                                     │
│───────────────────────────────────────────────────────────────────│
│  ✔  Running phase [Finalize] on 128 classes                       │
│  ✔  Running phase [Finalize] on 1044 method groups                │
│  ✔  Running phase [Finalize] on 1228 methods                      │
│  Found 0 issues |  Modified 0                                     │
└───────────────────────────────────────────────────────────────────┘

┌────────────────────────────[ Results ]────────────────────────────┐
│  Executed String Encryption [Success: 930 Skipped: 152 Failed: 0] │
│  Executed Interprocedural Harden [Success: 0 Skipped: 5 Failed: 0]│
│  Executed Interprocedural [Success: 0 Skipped: 0 Failed: 0]       │
│  Executed Number Encryption [Success: 930 Skipped: 152 Failed: 0] │
│  Executed Flow Switch [Success: 930 Skipped: 152 Failed: 0]       │
│  Executed Flow Condition [Success: 930 Skipped: 152 Failed: 0]    │
│  Executed Flow Exception [Success: 930 Skipped: 152 Failed: 0]    │
│  Executed Flow Range [Success: 930 Skipped: 152 Failed: 0]        │
│  Executed Pure Encryption [Success: 0 Skipped: 0 Failed: 0]       │
│  Executed Ahegao [Success: 123 Skipped: 5 Failed: 0]              │
└───────────────────────────────────────────────────────────────────┘

✔  Dumped 3251 classes
✔  Outputting 129 classes to lt/jars/DotMan-obf.jar-out.jar
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

No branches or pull requests

1 participant