Menu

#723 IllegalArgumentExc: Stack size negative after instruction [] invokestatic

v6.0
open
Medium
2019-03-31
2018-09-18
Fabio Santo
No

Hey guys, here another "IlleagalState: negative stack" exception when preparing for apk release.

Optimizing (pass 2/5)...
Unexpected error while computing stack sizes:
  Class       = [OUR_INTERNAL_CLASS]
  Method      = [doResume(Ljava/lang/Object;Ljava/lang/Throwable;)Ljava/lang/Object;]
  Exception   = [java.lang.IllegalArgumentException] (Stack size becomes negative after instruction [282] invokestatic #52 in [OUR_INTERNAL_CLASS$1.doResume(Ljava/lang/Object;Ljava/lang/Throwable;)Ljava/lang/Object;])
Warning: Exception while processing task java.io.IOException: java.lang.IllegalArgumentException: Stack size becomes negative after instruction [282] invokestatic #52 in [OUR_INTERNAL_CLASS$1.doResume(Ljava/lang/Object;Ljava/lang/Throwable;)Ljava/lang/Object;]
Thread(Tasks limiter_2): destruction

I could find many results around the JobSupport Class causing the crash but this looks different.

Tried to:
export with Proguard 6.0.1, 6.0.2, 6.0.3
-keep class kotlin.coroutines.experimental.* { ; }

Something to consider: in this specific class, we use coroutines in a function within a kotlin object.

Discussion

  • Fabio Santo

    Fabio Santo - 2018-09-18

    update: transforming the Kotlin object to a class fixes the problem

     
  • Mr Yang

    Mr Yang - 2019-03-31

    I meet the same problem too.I don't know why proguard will throw this exception and feel that the bytecode is good.

    Caused by: java.lang.IllegalArgumentException: Stack size becomes negative after instruction [18] invokestatic #76 in [com/facebook/stetho/common/Util.close(Ljava/io/Closeable;Z)V]
            at proguard.classfile.attribute.visitor.StackSizeComputer.evaluateInstructionBlock(StackSizeComputer.java:349)
            at proguard.classfile.attribute.visitor.StackSizeComputer.visitExceptionInfo(StackSizeComputer.java:277)
            at proguard.classfile.attribute.CodeAttribute.exceptionsAccept(CodeAttribute.java:153)
            at proguard.classfile.attribute.visitor.StackSizeComputer.visitCodeAttribute0(StackSizeComputer.java:166)
            at proguard.classfile.attribute.visitor.StackSizeComputer.visitCodeAttribute(StackSizeComputer.java:125)
            at proguard.classfile.editor.StackSizeUpdater.visitCodeAttribute(StackSizeUpdater.java:49)
            at proguard.classfile.editor.MemberReferenceFixer.visitCodeAttribute(MemberReferenceFixer.java:322)
            at proguard.classfile.attribute.CodeAttribute.accept(CodeAttribute.java:101)
            at proguard.classfile.ProgramMethod.attributesAccept(ProgramMethod.java:81)
            at proguard.classfile.editor.MemberReferenceFixer.visitProgramMember(MemberReferenceFixer.java:285)
            at proguard.classfile.util.SimplifiedVisitor.visitProgramMethod(SimplifiedVisitor.java:92)
            at proguard.classfile.ProgramMethod.accept(ProgramMethod.java:73)
            at proguard.classfile.ProgramClass.methodsAccept(ProgramClass.java:516)
            at proguard.classfile.editor.MemberReferenceFixer.visitProgramClass(MemberReferenceFixer.java:82)
            at proguard.classfile.ProgramClass.accept(ProgramClass.java:358)
            at proguard.classfile.ClassPool.classesAccept(ClassPool.java:124)
            at proguard.optimize.Optimizer.execute(Optimizer.java:590)
            at proguard.ProGuard.optimize(ProGuard.java:328)
            at proguard.ProGuard.execute(ProGuard.java:127)
            at com.android.build.gradle.internal.transforms.BaseProguardAction.runProguard(BaseProguardAction.java:61)
            at com.android.build.gradle.internal.transforms.ProGuardTransform.doMinification(ProGuardTransform.java:253)
            ... 6 more
    

    here is bytecode of the class

      public static void close(java.io.Closeable, boolean) throws java.io.IOException;
        descriptor: (Ljava/io/Closeable;Z)V
        flags: ACC_PUBLIC, ACC_STATIC
        Code:
          stack=2, locals=3, args_size=2
             0: aload_0
             1: ifnull        33
             4: iload_1
             5: ifeq          27
             8: aload_0
             9: invokeinterface #83,  1           // InterfaceMethod java/io/Closeable.close:()V
            14: goto          33
            17: astore_2
            18: aload_2
            19: ldc           #85                 // String Hiding IOException because another is pending
            21: invokestatic  #91                 // Method com/facebook/stetho/common/LogUtil.e:(Ljava/lang/Throwable;Ljava/lang/String;)V
            24: goto          33
            27: aload_0
            28: invokeinterface #83,  1           // InterfaceMethod java/io/Closeable.close:()V
            33: return
          Exception table:
             from    to  target type
                 8    14    17   Class java/io/IOException
          StackMapTable: number_of_entries = 3
            frame_type = 81 /* same_locals_1_stack_item */
              stack = [ class java/io/IOException ]
            frame_type = 9 /* same */
            frame_type = 5 /* same */
          LineNumberTable:
            line 76: 0
            line 77: 4
            line 79: 8
            line 82: 14
            line 80: 17
            line 81: 18
            line 82: 24
            line 84: 27
            line 87: 33
          LocalVariableTable:
            Start  Length  Slot  Name   Signature
               18       6     2     e   Ljava/io/IOException;
                0      34     0 closeable   Ljava/io/Closeable;
                0      34     1 hideException   Z
        Exceptions:
          throws java.io.IOException
    
     

Log in to post a comment.

MongoDB Logo MongoDB