Menu

#708 Corrupted stack map frames after transformation

v6.0
closed-fixed
None
Medium
2019-05-14
2018-06-06
No

After proguarding (v. 6.0.3) next code JVM fails with VerificationError:

package test

import java.io.InputStream

open class Base(val name: String)

class Foo(stream: InputStream) : Base(stream.use {
    val z = "foo"

    if (z.isEmpty()) {
        throw UnsupportedOperationException("bar")
    }

    z

})

fun main(args: Array<String>) {
    Foo("123".byteInputStream()).name
}

VerificationError:

java -cp test_out.jar:kotlin-runtime.jar test.MainKt
Exception in thread "main" java.lang.VerifyError: Stack map does not match the one at exception handler 66
Exception Details:
Location:
test/b.<init>(Ljava/io/InputStream;)V @66: dup
Reason:
Current frame's flags are not assignable to stack map frame's.
Current Frame:
bci: @16
flags: { flagThisUninit }
locals: { uninitializedThis, 'java/io/Closeable', null, top, top, uninitializedThis }
stack: { 'java/lang/Throwable' }
Stackmap Frame:
bci: @66
flags: { }
locals: { top, 'java/io/Closeable', null }
stack: { 'java/lang/Throwable' }
Bytecode:
0x0000000: 2b12 03b8 0010 2a2b c000 044c 3a05 014d
0x0000010: 1202 594e c000 0659 3a04 b900 1201 009a
0x0000020: 0007 04a7 0004 0399 0010 bb00 0959 1201
0x0000030: b700 0ec0 0008 bf2d 4e2b 01b8 000f 2da7
0x0000040: 0010 594e 4d2d bf4e 2b2c b800 0f2d bf4c
0x0000050: 1905 2bb7 0011 b1
Exception Handler Table:
bci [16, 57] => handler: 66
bci [16, 57] => handler: 71
bci [66, 71] => handler: 71
Stackmap Table:
full_frame(@38,{UninitializedThis,Object[#4],Null,Object[#7],Top,UninitializedThis},{})
same_locals_1_stack_item_frame(@39,Integer)
same_frame(@55)
full_frame(@66,{Top,Object[#4],Null},{Object[#8]})
full_frame(@71,{Top,Object[#4],Object[#8]},{Object[#8]})
full_frame(@79,{UninitializedThis,Top,Top,Top,Top,UninitializedThis},{Object[#7]})</init>

at test.MainKt.main(Unknown Source)

3 Attachments

Related

Bugs: #4
Bugs: #7
Bugs: #8

Discussion

  • max-kammerer

    max-kammerer - 2018-06-06

    Same problem also in 5.3.3

     
  • Eric Lafortune

    Eric Lafortune - 2018-08-15

    Thanks for your detailed report. It helped greatly to reproduce the problem. The bug is triggered by bytecode that Java can't generate, but Kotlin can. It has now been fixed for the upcoming ProGuard 6.1.

     
  • Eric Lafortune

    Eric Lafortune - 2018-08-15
    • status: open --> open-fixed
    • assigned_to: Eric Lafortune
     
  • Eric Lafortune

    Eric Lafortune - 2019-05-14
    • Status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB