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

Incorrect update of LocalVariableTable when local variable uses the slot of parameter #1430

Open
Godin opened this issue Apr 29, 2023 · 0 comments
Labels
component: core type: bug 🐛 Something isn't working

Comments

@Godin
Copy link
Member

Godin commented Apr 29, 2023

Local variables can use slots of parameters (cf #767, #1412, #1429), therefore change that was done in 70d5b98 (#1246) seems suspicious/incomplete/incorrect.

Below are relevant parts of javap -v -p output which demonstrate the problem using the following Example.kt

inline fun <R> example(priority: Int = 0, block: () -> R): R {
    val start = System.currentTimeMillis()
    val result = block()
    val elapsed = (System.currentTimeMillis() - start)
    return result
}

after compilation by Kotlin 1.8.20

  public static java.lang.Object example$default(int, kotlin.jvm.functions.Function0, int, java.lang.Object);
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
           16      22     2 $i$f$example   I
           20      18     3 start   J
           28      10     5 result   Ljava/lang/Object;
           35       3     6 elapsed   J
            0      38     0 priority   I
            0      38     1 block   Lkotlin/jvm/functions/Function0;

after instrumentation by JaCoCo 0.8.7

  public static java.lang.Object example$default(int, kotlin.jvm.functions.Function0, int, java.lang.Object);
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
           40      40     2 $i$f$example   I
           50      30     3 start   J
           64      16     6 result   Ljava/lang/Object;
           71       9     7 elapsed   J
            5      75     0 priority   I
            5      75     1 block   Lkotlin/jvm/functions/Function0;

and after instrumentation by JaCoCo 0.8.8

  public static java.lang.Object example$default(int, kotlin.jvm.functions.Function0, int, java.lang.Object);
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0      80     2 $i$f$example   I
            0      80     3 start   J
           64      16     6 result   Ljava/lang/Object;
           71       9     7 elapsed   J
            0      80     0 priority   I
            0      80     1 block   Lkotlin/jvm/functions/Function0;
@Godin Godin added type: bug 🐛 Something isn't working component: core labels Apr 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: core type: bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant