Guardsquare / proguard

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

java.lang.VerifyError: Bad return type #386

Open sproctor opened 7 months ago

sproctor commented 7 months ago

This error only happens with Proguard 7.4.x. Adding -dontoptimize or reverting to 7.2.2 gets rid of the crash.

java.lang.VerifyError: Bad return type
Exception Details:
  Location:
    b/b/e/cb.a(Lkotlin/jvm/functions/Function0;)Lb/b/e/V; @18: areturn
  Reason:
    Type 'b/b/e/ct' (current frame, stack[0]) is not assignable to 'b/b/e/V' (from method signature)
  Current Frame:
    bci: @18
    flags: { }
    locals: { 'kotlin/jvm/functions/Function0' }
    stack: { 'b/b/e/ct' }
  Bytecode:
    0000000: 2a12 06b8 0016 bb00 0759 2a01 b700 11c0
    0000010: 000c b0                                

    at b.b.e.t.b(SourceFile:51531)
    at b.b.e.t.a(SourceFile:3236)
    at b.b.e.E.c(SourceFile:723)
    at b.b.e.bi.a(SourceFile:1071)
    at b.b.e.E.d(SourceFile:631)
    at b.b.e.E.a(SourceFile:617)
    at b.b.f.u.i.invokeSuspend(SourceFile:219)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(SourceFile:33)
    at kotlinx.coroutines.DispatchedTask.run(SourceFile:108)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
    at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
    at java.base/java.security.AccessController.doPrivileged(Unknown Source)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)

Proguard 7.3.2 has a different error:

java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    b/b/e/cg.a(Lkotlinx/coroutines/flow/Flow;Ljava/lang/Object;Lkotlin/coroutines/CoroutineContext;Lb/b/e/q;II)Lb/b/e/cu; @92: invokestatic
  Reason:
    Type 'kotlin/jvm/functions/Function2' (current frame, stack[3]) is not assignable to 'b/b/e/ch'
  Current Frame:
    bci: @92
    flags: { }
    locals: { 'kotlinx/coroutines/flow/Flow', 'java/lang/Object', 'kotlin/coroutines/CoroutineContext', 'b/b/e/q', integer }
    stack: { 'java/lang/Object', 'kotlinx/coroutines/flow/Flow', 'kotlin/coroutines/CoroutineContext', 'kotlin/jvm/functions/Function2', 'b/b/e/q', integer }
  Bytecode:
    0000000: 2a12 07b8 0022 2d12 01b9 0023 0200 1505
    0000010: 057e 9900 0ab2 001a c000 154d b800 1b99
    0000020: 0019 1201 1504 0212 083a 0636 0536 0536
    0000030: 0519 0612 07b8 0022 2b2a 2cbb 000e 592c
    0000040: 2a01 b700 20c0 0017 2d11 1240 1008 1504
    0000050: 067a 7e80 100e 1504 067a 7e80 b800 1f4b
    0000060: 2db9 0024 0100 2ab0                    
  Stackmap Table:
    chop_frame(@28,1)
    same_frame(@56)

    at b.b.e.cb.a(Unknown Source)
    ...

Proguard 7.2.2 works fine.

sproctor commented 2 months ago

Still existing in 7.5.0.

mrjameshamilton commented 2 months ago

Hi @sproctor ! Can you share a reproducing sample?