Bug 546976 - Gerrit Jenkins jobs report comparator warnings which are not reported by official builds
Summary: Gerrit Jenkins jobs report comparator warnings which are not reported by offi...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Releng (show other bugs)
Version: 4.12   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 4.12 M3   Edit
Assignee: Dani Megert CLA
QA Contact:
URL:
Whiteboard:
Keywords: greatbug
Depends on: 506778
Blocks:
  Show dependency tree
 
Reported: 2019-05-04 09:31 EDT by Dani Megert CLA
Modified: 2019-05-10 09:23 EDT (History)
6 users (show)

See Also:


Attachments
built class disassembled (10.07 KB, application/octet-stream)
2019-05-06 03:00 EDT, Sravan Kumar Lakkimsetti CLA
no flags Details
baseline class disassembled (10.07 KB, application/octet-stream)
2019-05-06 03:01 EDT, Sravan Kumar Lakkimsetti CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2019-05-04 09:31:59 EDT
Gerrit Jenkins jobs (all projects) report comparator warnings which are not reported by official build.

Example:

https://ci.eclipse.org/platform/job/eclipse.platform.ui-Gerrit/18021/warnings39Result/source.6626726096164242840/#14795

[WARNING] MavenProject: eclipse.platform.ui:org.eclipse.core.commands:3.9.400-SNAPSHOT @ /home/cbi/genie.platform/workspace/eclipse.platform.ui-Gerrit@2/bundles/org.eclipse.core.commands/.polyglot.build.properties: baseline and build artifacts have same version but different contents
no-classifier: different
org/eclipse/core/commands/Command.class: different
org/eclipse/core/commands/ParameterizedCommand.class: different
org/eclipse/core/commands/common/NamedHandleObjectComparator.class: different
org/eclipse/core/commands/operations/DefaultOperationHistory.class: different
org/eclipse/core/commands/operations/TriggeredOperations.class: different
org/eclipse/core/internal/commands/util/Util.class: different
[INFO] MavenProject: eclipse.platform.ui:org.eclipse.core.commands:3.9.400-SNAPSHOT @ /home/cbi/genie.platform/workspace/eclipse.platform.ui-Gerrit@2/bundles/org.eclipse.core.commands/.polyglot.build.properties
The main artifact has been replaced with the baseline version.
Comment 1 Dani Megert CLA 2019-05-04 09:38:39 EDT
Some findings from the ongoing investigation done by Sravan and me.

- A job updates parent pom on Gerrit Jenkins from master every hour
	==> same ECJ is used for Gerrit
	==> same Tycho is used for Gerrit (and hence same comparator)

- Baseline is correct

- JRE used to compile is the same

- !!! JRE used by Tycho/comparator is NOT the same. Build uses JRE from /shared and Gerrit  Jenkins uses the default one from Jenkins. This can be changed according to Sravan:
	There is a way to add JDK: https://ci.eclipse.org/platform/configureTools/

- The above difference is most likely the problem:
  javap -verbose differs when using the JRE from build vs. the one from Jenkins
	NOTE: it does not differ if -verbose is not used


Sravan will try to use the JRE from /shared in Gerrit's Jenkins jobs.
Comment 2 Sravan Kumar Lakkimsetti CLA 2019-05-06 02:09:03 EDT
I went though the code code for Tycho's comparator,

Here are my observations.
1. Tycho tries to disassemble baseline and built classes using asm 7 with SKIP_DEBUG and SKIP_FRAMES flags
2. Do special processing for PACK200 Normalized classes
3. Compare the output 

if there is a problem in disassembly binary comparison us used.

I am using javap for disassembly till now. javap -c generates different disassembled code for baseline and built class files. This happens with same jre. 

I think JRE is not an issue here. 

Regarding the JRE for official build and Gerrit build we are using the same JRE for both.
In official build the following jre is used
JAVA_HOME="/shared/common/jdk1.8.0_x64-latest"

In Gerrit build we are using the same.
/shared/common/jdk1.8.0_x64-latest

My suspicion is on the pack200. There is a special processing for pack200 normalized classes in the comparator. 

In gerrit comparison the baseline class is pack200 normalized and built class is not
Comment 3 Sravan Kumar Lakkimsetti CLA 2019-05-06 03:00:47 EDT
Created attachment 278497 [details]
built class disassembled
Comment 4 Sravan Kumar Lakkimsetti CLA 2019-05-06 03:01:14 EDT
Created attachment 278498 [details]
baseline class disassembled
Comment 5 Sravan Kumar Lakkimsetti CLA 2019-05-06 03:04:05 EDT
The attached ones are from gerrit job. there is definitely some change. Need some help in understanding the changes listed here

@Jay can you help here?
Comment 6 Sravan Kumar Lakkimsetti CLA 2019-05-06 03:05:01 EDT
(In reply to Sravan Kumar Lakkimsetti from comment #3)
> Created attachment 278497 [details]
> built class disassembled

(In reply to Sravan Kumar Lakkimsetti from comment #4)
> Created attachment 278498 [details]
> baseline class disassembled


I created a small test program using asm to disassemble class files. The above files are out of that
Comment 7 Dani Megert CLA 2019-05-06 03:25:23 EDT
Could it be that we had those warnings for a long time and just no one observed/reported them?
Comment 8 Sravan Kumar Lakkimsetti CLA 2019-05-06 04:11:27 EDT
(In reply to Dani Megert from comment #7)
> Could it be that we had those warnings for a long time and just no one
> observed/reported them?

It could be a possibility Dani
Comment 9 Sravan Kumar Lakkimsetti CLA 2019-05-06 05:55:12 EDT
After some more analysis I found this

With pomless builds, maven creates .polyglot.build.properties file for build purposes. This is causing the comparator to fail in our gerrit builds. 

To test my theory I am going to revert pomless change for org.eclipse.core.commands now and will verify gerrit build tomorrow. 

Reverting would update the qualifier. So the comparator won't even attempt for comparison till there is a new baseline.
Comment 10 Eclipse Genie CLA 2019-05-06 05:59:16 EDT
New Gerrit change created: https://git.eclipse.org/r/141653
Comment 12 Sravan Kumar Lakkimsetti CLA 2019-05-07 01:47:48 EDT
(In reply to Eclipse Genie from comment #11)
> Gerrit change https://git.eclipse.org/r/141653 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/
> ?id=34a4bc6cde838145488624f3c81e01e24cef9d95

Last night's build did not create a new bundle for baseline. So I am triggering a new build shortly
Comment 13 Eclipse Genie CLA 2019-05-07 01:52:40 EDT
New Gerrit change created: https://git.eclipse.org/r/141692
Comment 15 Jay Arthanareeswaran CLA 2019-05-07 02:17:04 EDT
Looks like the differing code corresponds to the inlined icuBigDecimal.getConstructor() => Class.getConstructor(), which has changed between 1.8 and 12.

As Dani said, what might be causing this is the JDK used by Tycho, which also means a different system libraries are used for compilation.
Comment 16 Mickael Istria CLA 2019-05-07 02:59:53 EDT
If it's a baseline issue caused by pomless build, then adding the .polyglot.build.properties to the various excludes in parent pom should help.
Comment 17 Eclipse Genie CLA 2019-05-07 03:05:31 EDT
New Gerrit change created: https://git.eclipse.org/r/141694
Comment 18 Dani Megert CLA 2019-05-07 03:29:18 EDT
(In reply to Mickael Istria from comment #16)
> If it's a baseline issue caused by pomless build, then adding the
> .polyglot.build.properties to the various excludes in parent pom should help.
The differences are not from having that file but from class file differences
Comment 19 Jay Arthanareeswaran CLA 2019-05-07 04:16:35 EDT
(In reply to Jay Arthanareeswaran from comment #15)
> Looks like the differing code corresponds to the inlined
> icuBigDecimal.getConstructor() => Class.getConstructor(), which has changed
> between 1.8 and 12.
> 
> As Dani said, what might be causing this is the JDK used by Tycho, which
> also means a different system libraries are used for compilation.

Unfortunately I am unable to back this up with a reproducible small test. Will continue to look at this from the compiler perspective.
Comment 20 Sravan Kumar Lakkimsetti CLA 2019-05-07 04:57:36 EDT
Even after adding pom.xml I am seeing comparator errors. Need to take a fresh look on this issue.

476 [WARNING] MavenProject: org.eclipse.core:org.eclipse.core.commands:3.9.400-SNAPSHOT @ /home/sravanl/git/eclipse.platform.releng.aggregator/eclipse.platform.ui/bundles/org.eclipse.core.commands/pom.xml: baseline and build artifacts ha    ve same version but different contents
477    no-classifier: different
478       org/eclipse/core/commands/Command.class: different
479       org/eclipse/core/commands/ParameterizedCommand.class: different
480       org/eclipse/core/commands/common/NamedHandleObjectComparator.class: different
481       org/eclipse/core/commands/operations/DefaultOperationHistory.class: different
482       org/eclipse/core/commands/operations/TriggeredOperations.class: different
483       org/eclipse/core/internal/commands/util/Util.class: different
484
485 [INFO] MavenProject: org.eclipse.core:org.eclipse.core.commands:3.9.400-SNAPSHOT @ /home/sravanl/git/eclipse.platform.releng.aggregator/eclipse.platform.ui/bundles/org.eclipse.core.commands/pom.xml
486     The main artifact has been replaced with the baseline version.
487     The following attached artifacts have been replaced with the baseline version: [sources]
Comment 21 Jay Arthanareeswaran CLA 2019-05-07 06:07:00 EDT
(In reply to Jay Arthanareeswaran from comment #15)
> Looks like the differing code corresponds to the inlined
> icuBigDecimal.getConstructor() => Class.getConstructor(), which has changed
> between 1.8 and 12.

This isn't true. The differing code is about the three empty blocks. And for the same empty block we seem to be generating different byte code now comparing with the baseline.

IMO, this is a clear case of something different either in the source code or the compiler. I just don't know what it is yet.
Comment 22 Dani Megert CLA 2019-05-07 07:46:50 EDT
(In reply to Jay Arthanareeswaran from comment #21)
> (In reply to Jay Arthanareeswaran from comment #15)
> > Looks like the differing code corresponds to the inlined
> > icuBigDecimal.getConstructor() => Class.getConstructor(), which has changed
> > between 1.8 and 12.
> 
> This isn't true. The differing code is about the three empty blocks. And for
> the same empty block we seem to be generating different byte code now
> comparing with the baseline.
> 
> IMO, this is a clear case of something different either in the source code
> or the compiler. I just don't know what it is yet.
Sravan, is Gerrit using the same ECJ version than the official build?
Comment 23 Sravan Kumar Lakkimsetti CLA 2019-05-07 23:25:00 EDT
It is the same ecj compiler that is used in both official build and Gerrit build

compiler gets downloaded here in case of gerrit https://ci.eclipse.org/platform/view/Gerrit/job/eclipse.platform.ui-Gerrit/ws/.repository/org/eclipse/jdt/ecj/3.18.0.v20190430-1056/

incase of daily build eco gets downloaded here https://build.eclipse.org/eclipse/builds/4I/localMavenRepo/org/eclipse/jdt/ecj/3.18.0.v20190430-1056/

They both gets downloaded from https://repo.eclipse.org/content/repositories/eclipse-staging/org/eclipse/jdt/ecj/

The compiler selection is based on the cbi-ecj-version in parent pom. 

For gerrit the parent pom is pulled in(latest will get pulled) from https://repo.eclipse.org/content/repositories/eclipse-snapshots/org/eclipse/eclipse-platform-parent/4.12.0-SNAPSHOT/

and in case of regular build we have parent pom in our source. https://git.eclipse.org/c/platform/eclipse.platform.releng.aggregator.git/tree/eclipse-platform-parent/pom.xml

These two are synced up using https://ci.eclipse.org/releng/job/deploy-eclipse-platform-parent-pom-4.12/ this job runs hourly
Comment 24 Sravan Kumar Lakkimsetti CLA 2019-05-07 23:51:16 EDT
For confirmation you can see the version information here

compile log for Gerrit: https://ci.eclipse.org/platform/job/eclipse.platform.ui-Gerrit/ws/bundles/org.eclipse.core.commands/target/compilelogs/@dot.xml

compile log for daily build: http://download.eclipse.org/eclipse/downloads/drops4/I20190507-1800/compilelogs/plugins/org.eclipse.core.commands_3.9.400.v20190507-0554/@dot.xml

both have version="v20190430-1056, 3.18.0"
Comment 25 Jay Arthanareeswaran CLA 2019-05-08 06:30:40 EDT
> This isn't true. The differing code is about the three empty blocks. And for
> the same empty block we seem to be generating different byte code now
> comparing with the baseline.

I meant to say, empty catch blocks. It still beats me why we would do that. I still can't reproduce this even trying several compiler code generation options :(
Comment 26 Sravan Kumar Lakkimsetti CLA 2019-05-08 23:31:32 EDT
I am trying doing one more test. 

Trying out Tycho version 1.3.0
Comment 27 Eclipse Genie CLA 2019-05-08 23:38:53 EDT
New Gerrit change created: https://git.eclipse.org/r/141850
Comment 29 Eclipse Genie CLA 2019-05-08 23:48:11 EDT
New Gerrit change created: https://git.eclipse.org/r/141851
Comment 31 Sravan Kumar Lakkimsetti CLA 2019-05-08 23:51:27 EDT
(In reply to Sravan Kumar Lakkimsetti from comment #26)
> I am trying doing one more test. 
> 
> Trying out Tycho version 1.3.0

Getting the same issue by downgrading also
Comment 32 Jay Arthanareeswaran CLA 2019-05-09 01:14:15 EDT
I am wondering about the usage of the -inlineJSR compiler option. Do we know if this is same in the official build too?
Comment 33 Sravan Kumar Lakkimsetti CLA 2019-05-09 01:57:10 EDT
(In reply to Jay Arthanareeswaran from comment #32)
> I am wondering about the usage of the -inlineJSR compiler option. Do we know
> if this is same in the official build too?

here is the compile log containing commandline options. https://download.eclipse.org/eclipse/downloads/drops4/I20190508-1800/compilelogs/plugins/org.eclipse.core.commands_3.9.400.v20190507-0554/@dot.xml

-inlineJSR is used in official build as well
Comment 34 Jay Arthanareeswaran CLA 2019-05-09 04:34:26 EDT
(In reply to Jay Arthanareeswaran from comment #32)
> I am wondering about the usage of the -inlineJSR compiler option. Do we know
> if this is same in the official build too?

This is also red herring. I am seeing this code in TryStatement#generateCode() that appear to be generating the two versions of the code we are discussing:

if ((catchVar = this.catchArguments[i].binding).resolvedPosition != -1) {
	codeStream.store(catchVar, false);
	catchVar.recordInitializationStartPC(codeStream.position);
	codeStream.addVisibleLocalVariable(catchVar);
} else {
	codeStream.pop();
}

Continuing...
Comment 35 Jay Arthanareeswaran CLA 2019-05-09 04:53:01 EDT
Phew, this is our old friend option preserve Local variable. Looks like this is on in build and off in gerrits!
Comment 36 Dani Megert CLA 2019-05-09 05:18:14 EDT
(In reply to Jay Arthanareeswaran from comment #35)
> Phew, this is our old friend option preserve Local variable. Looks like this
> is on in build and off in gerrits!

Where is it set? How can it be different?
Comment 37 Sravan Kumar Lakkimsetti CLA 2019-05-10 00:18:08 EDT
(In reply to Dani Megert from comment #36)
> (In reply to Jay Arthanareeswaran from comment #35)
> > Phew, this is our old friend option preserve Local variable. Looks like this
> > is on in build and off in gerrits!
> 
> Where is it set? How can it be different?

it is set in root pom.xml of platform.ui, introduced by bug 506778

This change causes gerrit and regular build to have different compiler options.
Comment 38 Dani Megert CLA 2019-05-10 06:03:23 EDT
(In reply to Sravan Kumar Lakkimsetti from comment #37)
> (In reply to Dani Megert from comment #36)
> > (In reply to Jay Arthanareeswaran from comment #35)
> > > Phew, this is our old friend option preserve Local variable. Looks like this
> > > is on in build and off in gerrits!
> > 
> > Where is it set? How can it be different?
> 
> it is set in root pom.xml of platform.ui, introduced by bug 506778
> 
> This change causes gerrit and regular build to have different compiler
> options.
That at first did not help because the option is on (preserve) in the default workspace and in the projects.

Now, reading the Javadoc for that options reveals it:

	/**
	 * Compiler option ID: Preserving Unused Local Variables.
	 * <p>Unless requested to preserve unused local variables (that is, never read), the
	 *    compiler will optimize them out, potentially altering debugging.</p>
	 * <dl>
	 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.codegen.unusedLocal"</code></dd>
	 * <dt>Possible values:</dt><dd><code>{ "preserve", "optimize out" }</code></dd>
	 * <dt>Default:</dt><dd><code>"preserve"</code></dd>
	 * </dl>
	 * @category CompilerOptionID
	 */

==> Since the option is not specified when using ECJ, the option is set to off (optimize out). This is what we see in our official build. However for the IDE/JavaCorePreferenceInitializer the option is on (preserve) and that's also what's in the project settings file.

I will try to verify that with the upcoming Gerrit change.
Comment 39 Eclipse Genie CLA 2019-05-10 06:06:29 EDT
New Gerrit change created: https://git.eclipse.org/r/141947
Comment 40 Dani Megert CLA 2019-05-10 08:06:47 EDT
(In reply to Eclipse Genie from comment #39)
> New Gerrit change created: https://git.eclipse.org/r/141947
That did not work, but reverting the change for bug 506778 fixes the issue (see bug 540419).
Comment 41 Dani Megert CLA 2019-05-10 08:10:30 EDT
(In reply to Dani Megert from comment #40)
> (In reply to Eclipse Genie from comment #39)
> > New Gerrit change created: https://git.eclipse.org/r/141947
> That did not work
Reason: -properties overrides most of the arguments and wins.
Comment 42 Dani Megert CLA 2019-05-10 09:23:10 EDT
Fixed by reverting the changes from bug 506778.

Thanks everyone for your effort on this bug. We (or at least I) learned a lot!