Guardsquare / proguard

ProGuard, Java optimizer and obfuscator
https://www.guardsquare.com/en/products/proguard
GNU General Public License v2.0
2.87k stars 411 forks source link

[7.3.1] java.lang.VerifyError #307

Open boris-petrov opened 1 year ago

boris-petrov commented 1 year ago

I updated from 7.3.0 to 7.3.1. At runtime I get a java.lang.VerifyError: Inconsistent stackmap frames at branch target 0. This is the only seemingly relevant thing:

  Reason:
    Type 'com/company/A' (current frame, locals[1]) is not assignable to 'com/company/A$B' (stack map, locals[1])

A$B extends A.

These are my configuration options:

optimizations '!class/merging/*' // TODO: ProGuard bug - https://github.com/Guardsquare/proguard/issues/17
overloadaggressively
allowaccessmodification
mergeinterfacesaggressively
keepparameternames
optimizationpasses 5
dontshrink
dontusemixedcaseclassnames
repackageclasses 'com.company'
adaptclassstrings
adaptresourcefilenames
adaptresourcefilecontents 'META-INF/services/*,WEB-INF/web.xml'
renamesourcefileattribute 'SourceFile'
keepattributes 'Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod'

Any ideas? Do you need a reproduction (which I guess will be difficult to do) or you can figure out what's going on only from this information?

boris-petrov commented 1 year ago

Same issue still happens on 7.3.2.

mrjameshamilton commented 1 year ago

Hi @boris-petrov ! Can you provide a reproducible sample?

Are you able to narrow down the issue by disabling ProGuard features and/or adding -keep rules?

boris-petrov commented 1 year ago

Hi, a reproducible sample will be rather difficult so I hope to have to do that as a last resort. As for disabling ProGuard features - I guess you mean customizing the optimizations? Any suggestions what should I try to disable?

mrjameshamilton commented 1 year ago

Hi @boris-petrov ! Unfortunately without a sample it will be difficult/impossible to fix this.

For narrowing down the issue: I would start broad, e.g. disabling optimization (-dontoptimize), then try disabling individual optimizations to try to narrow it down hopefully to a single optimization.

boris-petrov commented 1 year ago

OK, so I narrowed it down to the method/specialization/parametertype optimization. Without it, my code works fine. And as I mentioned, the issue was introduced between 7.3.0 and 7.3.1. Does that help you narrow down the problem?

mrjameshamilton commented 1 year ago

It's likely related to: Fix member specialization & generalization optimizations. . Commit here.

This was inadvertently broken some time in ~2020/2021 because a flag was not set (IS_CLASS_AVAILABLE) and a typo valueClass / program(Method|Field) so the optimization didn't run and then it was fixed with that commit; which is probably why it only became a problem with 7.3.1.

Can you share the specific class files that have the problem? com/company/A and com/company/A$B ?

boris-petrov commented 1 year ago

I sent you an email to the first email from the Contact page on your website. Let me know if you need anything more.

mrjameshamilton commented 1 year ago

I received your email, I didn't get a chance to look further into it yet. I'll update you if I find something.

mipastgt commented 1 year ago

This bug reported against JetBrains Compose multiplatform https://github.com/JetBrains/compose-multiplatform/issues/3387 seems to be related to this one and this one https://github.com/JetBrains/compose-multiplatform-core/pull/706 contains a very simple reproducer.

Paramood commented 10 months ago

Still reproducible in proguard 7.4.1.