missing local var table after instrumentation

77 views
Skip to first unread message

Alexey Loubyansky

unread,
Nov 2, 2021, 3:48:26 AM11/2/21
to JaCoCo and EclEmma Users
Hello,

it looks like the local variable table is missing after instrumentation in some cases.
This was manifested in a Quarkus issue [1] Although there is a workaround adding a compiler arg, there still seems to be an issue with the instrumentation. Will it be worth creating an issue?


Thanks,
Alexey

Marc Hoffmann

unread,
Nov 2, 2021, 5:56:29 AM11/2/21
to JaCoCo and EclEmma Users
Hi Alexey,

thanks for raising this issue.

I think JaCoCo does the following:

* The original local variable table is preserved
* JaCoCo adds a *synthetic* method $jacocoInit which has no corresponding source, therefore no var table
* JaCoCo adds a additional local variable (for the probe array) which has no corresponding source, therefore no var table

Can you please give a specific instance, where the local variable table is missing?

Thanks,
-marc



--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/129a49d3-d611-419c-a601-ef979cf0119en%40googlegroups.com.

Alexey Loubyansky

unread,
Nov 2, 2021, 6:24:18 AM11/2/21
to JaCoCo and EclEmma Users
Hi Marc,

thanks for your response. I can describe what I was observing but I am not sure I'll be able to provide the necessary details to conclude where the info gets lost.

In our case we are scanning the classpath looking for methods with specific annotations and then we are trying to figure out the method parameter names (among other things) using the Jandex library [1]. It appears Jandex does not actually require classes to be compiled with the `-parameters` argument to figure it out, it may pull the info from the local var table instead, IIUC.
So, we have a Quarkus JaCoCo extension that allows to integrate JaCoCo into Quarkus tests. The extension calls the JaCoCo instrumenter API here [2]. If instead of returning the `enhanced` byte array I return the original `bytes` array, Jandex can figure out the method parameter names. I we return the `enhanced` array, Jandex fails to figure it out. If we compile the classes with the `-parameters` argument though, it works.
I realize we need to debug this further to provide more info for you about what exactly Jandex is looking for in this case. But I thought I would still report the issue just in case it rings a bell.

Thanks,
Alexey

Marc Hoffmann

unread,
Nov 2, 2021, 8:47:18 AM11/2/21
to JaCoCo and EclEmma Users
Hi Alexey,

if I look at the stack trace of the original ticket I assume that this is not a problem with Jandex, but the code which makes assumptions about the data collected with Jandex. So I don’t think we can debug this from our side.

Please feel free to to get in touch again, as soon as you can pinpoint the issue down to JaCoCo.

Thanks,
-marc

Alexey Loubyansky

unread,
Nov 2, 2021, 5:01:42 PM11/2/21
to JaCoCo and EclEmma Users
Hi Marc,

right, the summary of the issue I referenced isn't specific enough for you. I quickly put together a simple reproducer [1] but I haven't yet actually debugged the Jandex code. It looks like the relevant method is [2] and line [3].


Hope that helps.

Thanks,
Alexey
Message has been deleted

Alexey Loubyansky

unread,
Nov 2, 2021, 5:27:13 PM11/2/21
to JaCoCo and EclEmma Users
Actually, since the parameters aren't enabled in the compiler, it's actually this method https://github.com/wildfly/jandex/blob/2.4.1.Final/src/main/java/org/jboss/jandex/Indexer.java#L645

Before the instrumentation, the `debugParameterNames` gets initialized with `greeting` but after the instrumentation it's not.

Marc Hoffmann

unread,
Nov 3, 2021, 4:52:38 AM11/3/21
to JaCoCo and EclEmma Users
Hi Alexey,

thanks a lot for providing the reproducer, very helpful!

I will debug this and see how we can make Jandex work together with JaCoCo.

Cheers,
-marc

Alexey Loubyansky

unread,
Nov 3, 2021, 5:22:51 AM11/3/21
to JaCoCo and EclEmma Users
That'll be awesome! Thanks, Marc!

Marc Hoffmann

unread,
Nov 3, 2021, 12:51:30 PM11/3/21
to JaCoCo and EclEmma Users
Hi Alexey,

I think I found the problem. This is the table before instrumentation:

      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       1     0  this   LExample;
            0       1     1 greeting   Ljava/lang/String;

and this is the table after instrumentation:

      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            6       5     0  this   LExample;
            6       5     1 greeting   Ljava/lang/String;

JaCoCo inserts initialization code at the beginning of every method. Technically the parameters are still valid from the first position on and their instruction range should not be moved by JaCoCo (JaCoCo will never use these slots). Now in Jandex there is a check that method parameter names must be valid from instruction 0 on:


Honestly I never thought about the LocalVariableTable. I will try to find out how this is handled in ASM and how this can be fixed in JaCoCo.

Cheers,
-marc


Message has been deleted

Alexey Loubyansky

unread,
Nov 3, 2021, 3:50:23 PM11/3/21
to JaCoCo and EclEmma Users
Hi Marc,

good to know the cause! It'd be really great if it could be fixed in JaCoCo.

Thanks a lot for your efforts!

Alexey

Message has been deleted

Marc Hoffmann

unread,
Nov 7, 2021, 4:03:07 PM11/7/21
to jac...@googlegroups.com
Hi Alexey,

here is a fix for review and test:


You reproducer in running without failure.

Cheers,
-marc



Alexey Loubyansky

unread,
Nov 8, 2021, 6:55:46 AM11/8/21
to JaCoCo and EclEmma Users
Hi Marc, this is really great, I'll check it out and let you know how it worked. Thanks a lot!

Alexey Loubyansky

unread,
Nov 8, 2021, 7:19:16 AM11/8/21
to JaCoCo and EclEmma Users
It works! Thanks again, Marc! Looking forward to the 0.8.8 release now.

Marc Hoffmann

unread,
Nov 8, 2021, 7:22:07 AM11/8/21
to jac...@googlegroups.com
Can you please quickly document your test in a comment to the Pull Request?

Alexey Loubyansky

unread,
Nov 8, 2021, 7:38:59 AM11/8/21
to JaCoCo and EclEmma Users
Done.
Reply all
Reply to author
Forward
0 new messages