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

java.lang.VerifyError: Bad return type #386

Open
sproctor opened this issue Feb 6, 2024 · 4 comments
Open

java.lang.VerifyError: Bad return type #386

sproctor opened this issue Feb 6, 2024 · 4 comments

Comments

@sproctor
Copy link

sproctor commented Feb 6, 2024

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 sproctor reopened this Jun 26, 2024
@sproctor
Copy link
Author

Still existing in 7.5.0.

@mrjameshamilton
Copy link
Contributor

Hi @sproctor ! Can you share a reproducing sample?

@sproctor
Copy link
Author

sproctor commented Oct 2, 2024

Sorry, I don't have an example to share. It seems to be Compose related.

Error with 7.6.0:

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

        at b.c.e.u.b(SourceFile:52298)
        at b.c.e.u.a(SourceFile:3522)
        at b.c.e.F.c(SourceFile:743)
        at b.c.e.bn.a(SourceFile:1122)
        at b.c.e.F.d(SourceFile:649)
        at b.c.e.F.a(SourceFile:635)
        at b.c.f.x.j.invokeSuspend(SourceFile:221)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(SourceFile:33)
        at kotlinx.coroutines.DispatchedTask.run(SourceFile:101)
        at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
        at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
        at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
        at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

From the mappings:

androidx.compose.runtime.ComposerImpl -> b.c.e.u:
# {"fileName":"Composer.kt","id":"sourceFile"}
    androidx.compose.runtime.Applier applier -> b
    androidx.compose.runtime.CompositionContext parentContext -> c
...
androidx.compose.runtime.DerivedSnapshotState -> b.c.e.X:
# {"fileName":"DerivedState.kt","id":"sourceFile"}
...
androidx.compose.runtime.State -> b.c.e.cA:
# {"fileName":"SnapshotState.kt","id":"sourceFile"}
    java.lang.Object getValue() -> b

Adding the following fixes the issue:

-keep class androidx.compose.runtime.* { *; }

@mrjameshamilton
Copy link
Contributor

Hi @sproctor ! It seems to be related to optimizations, if that's the case you could still allow shrinking and name obfuscation of the package with:

-keep,allowshrinking,allowobfuscation class androidx.compose.runtime.* { *; }

You could also disable specific optimizations, for example there is a known issue with enum simplication (#350):

-optimizations !class/unboxing/enum

If you can't share a full sample, it might help to share the bytecode for the specific class/method before and after, which you can dump with javap.

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

2 participants