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

Proguard replaces Methodref to InterfaceMethodref, but does not change instructions #48

Open
xxDark opened this issue Jun 17, 2020 · 8 comments
Labels
bug Potential bug in ProGuard.

Comments

@xxDark
Copy link

xxDark commented Jun 17, 2020

Hello.
We are using this awesome framework for our needs (https://github.com/SpongePowered/Mixin) and everything works fine.

However, Proguard breaks valid bytecode after obfuscation.
Before Proguard:

00000000 : aload_0
00000001 : invokevirtual       java.util.List hh.a()
00000004 : areturn

cp
After Proguard:
cp2

We will attempt to fix that issue in Mixin framework, however, can Proguard:
a) Also change instructions?
b) Don't touch constant pool in that case?
Thanks.

P.S The problem is that INVOKEVIRTUAL requires Methodref, not InterfaceMethodref. That change triggers JVM's verifier.

 java.lang.VerifyError: Illegal type at constant pool entry 6 in class hh
             Exception Details:
                Location:
                  hh.appendSibling(Lhh;)Lhh; @2: invokevirtual
                Reason:
                  Constant pool index 6 is invalid
                Bytecode:
                  0x0000000: 2a2b b600 06b0                         
                  	at qs.a(Unknown Source)
                  	at vi$a.<init>(Unknown Source)
                  	at vi.a(Unknown Source)
                  	at vi.c(Unknown Source)
                  	at ni.c(Unknown Source)
                  	at bib.<init>(Unknown Source)
@xxDark xxDark changed the title Proguard replaces INVOKEVIRTUAL to INVOKEINTERFACE, but does not change constant pool Proguard replaces Methodref to InterfaceMethodref, but does not change instructions Jun 17, 2020
@xxDark
Copy link
Author

xxDark commented Jun 17, 2020

SpongePowered/Mixin#413

@ingdas
Copy link
Member

ingdas commented Jun 17, 2020

Thanks for taking the time to report this to us. Would it be possible for you to provide us with a (minimal) example jar or source file to start from?

@xxDark
Copy link
Author

xxDark commented Jun 17, 2020

proguard.zip
java -cp . Test

@ingdas
Copy link
Member

ingdas commented Jun 17, 2020

Thanks for that. Can you also give us the same classes in a version which isn't processed by ProGuard (and thus working?). That way we can trace the execution and find out where it goes wrong.

@xxDark
Copy link
Author

xxDark commented Jun 17, 2020

Sure.
proguard.zip

@ingdas
Copy link
Member

ingdas commented Jun 17, 2020

I'll need to bother you once more. I can't replicate your error.

  • Are you sure you are using Proguard 7.0.0?
  • Have you set any extra configuration options for this sample? I tried the following standalone configuration:
-injars ./pre
-outjars ./output.jar

-libraryjars <java.home>/lib/rt.jar

-keep class Test {
	<methods>;
}

@xxDark
Copy link
Author

xxDark commented Jun 17, 2020

I guess that I provided not transformed class files, sorry.
Try on these:
dist.zip

@xxDark
Copy link
Author

xxDark commented Jun 17, 2020

Configuration:

-injars app-merged.jar
-outjars dist/app-proguard.jar

-libraryjars libs
-libraryjars <java.home>/lib/rt.jar

-dontshrink
-dontobfuscate
-optimizations class/marking/*,method/marking/*,method/inlining/tailrecursion,code/*
-optimizationpasses 1
-allowaccessmodification
-printmapping roguard.map
-overloadaggressively
-repackageclasses ''
-keepattributes *Annotations*,*Signature*,LineNumberTable,SourceFile
-verbose

-keepclassmembers enum  * {
    <fields>;
    <methods>;
}

-keep class App {
    void main(java.lang.String[]);
}

# Keep - Native method names. Keep all native class/method names.
-keepclasseswithmembers,includedescriptorclasses,allowshrinking class * {
    native <methods>;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Potential bug in ProGuard.
Projects
None yet
Development

No branches or pull requests

3 participants