Skip to content

Conversation

@kiszk
Copy link
Member

@kiszk kiszk commented Jun 12, 2018

What changes were proposed in this pull request?

This PR enables a Java bytecode check tool spotbugs to avoid possible integer overflow at multiplication. When an violation is detected, the build process is stopped.
Due to the tool limitation, some other checks will be enabled. In this PR, these patterns in FindPuzzlers can be detected.

This check is enabled at compile phase. Thus, mvn compile or mvn package launches this check.

How was this patch tested?

Existing UTs

@SparkQA
Copy link

SparkQA commented Jun 12, 2018

Test build #91720 has finished for PR 21542 at commit 3a356ad.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jun 15, 2018

Test build #91923 has finished for PR 21542 at commit 9cb534e.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@kiszk
Copy link
Member Author

kiszk commented Jun 15, 2018

After merging #21481, I confirmed build/mvn -DskipTests -T 8 clean compile does not find any violation by SpotBugs.

cc @cloud-fan @HyukjinKwon

@kiszk kiszk changed the title [WIP][SPARK-24529][Build] Add spotbugs into maven build process [SPARK-24529][Build] Add spotbugs into maven build process Jun 15, 2018
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it a real problem?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not a real problem. However, I cannot find to disable only this check in findPuzzles.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does it mean?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It means x % 2 == does not work correctly if x is negative.

In this case, we know value.length is always non-negative . The current SpotBugs cannot detect this pre-condition. I cannot find to disable only this check in findPuzzles, too.

Therefore, this is a workaround to avoid the false positive violation.

@kiszk kiszk changed the title [SPARK-24529][Build] Add spotbugs into maven build process [SPARK-24529][Build][test-maven] Add spotbugs into maven build process Jun 17, 2018
@HyukjinKwon
Copy link
Member

HyukjinKwon commented Jun 18, 2018

Sounds a good idea if what we all need is few changes like this. cc @srowen and @JoshRosen too who I believe might be interested in this too

Copy link
Member

@srowen srowen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have the code in front of me; is there a findbugs config in Spark? We can remove it if so after this.

I am OK with adding static analysis like this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure this Comparator never returns Int.MinValue? If it can, then this is still a legitimate possible bug.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. We cannot ensure it. ordering.compare(o2, o1) looks better.

@SparkQA
Copy link

SparkQA commented Jun 20, 2018

Test build #92112 has finished for PR 21542 at commit 75c9339.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@kiszk
Copy link
Member Author

kiszk commented Jun 20, 2018

retest this please

@SparkQA
Copy link

SparkQA commented Jun 20, 2018

Test build #92116 has finished for PR 21542 at commit 75c9339.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@kiszk
Copy link
Member Author

kiszk commented Jun 20, 2018

retest this please

@SparkQA
Copy link

SparkQA commented Jun 20, 2018

Test build #92125 has finished for PR 21542 at commit 75c9339.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@HyukjinKwon
Copy link
Member

Hmm .. retest this please

@SparkQA
Copy link

SparkQA commented Jun 20, 2018

Test build #92131 has finished for PR 21542 at commit 75c9339.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@kiszk
Copy link
Member Author

kiszk commented Jun 20, 2018

retest this please

@SparkQA
Copy link

SparkQA commented Jun 20, 2018

Test build #92139 has finished for PR 21542 at commit 75c9339.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@kiszk
Copy link
Member Author

kiszk commented Jun 20, 2018

retest this please

@SparkQA
Copy link

SparkQA commented Jun 21, 2018

Test build #92150 has finished for PR 21542 at commit 75c9339.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@HyukjinKwon
Copy link
Member

Hmm .. seems roughly the error looks consistent.

@kiszk
Copy link
Member Author

kiszk commented Jun 21, 2018

Unfortunately, looks consistent...

@SparkQA
Copy link

SparkQA commented Jun 21, 2018

Test build #92180 has finished for PR 21542 at commit 86ef42c.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@kiszk
Copy link
Member Author

kiszk commented Jun 22, 2018

Even when we stop forking SpotBugs, the same error occurred.
@HyukjinKwon is there any idea? I would appreciate your thoughts.

@SparkQA
Copy link

SparkQA commented Jul 4, 2018

Test build #92601 has finished for PR 21542 at commit b027d62.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jul 4, 2018

Test build #92609 has finished for PR 21542 at commit 191f135.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@kiszk
Copy link
Member Author

kiszk commented Jul 4, 2018

cc @cloud-fan @viirya @HyukjinKwon

<scope>test</scope>
</dependency>

<dependency>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is derived from the previous PR

@kiszk
Copy link
Member Author

kiszk commented Jul 9, 2018

ping @cloud-fan @viirya @HyukjinKwon

pom.xml Outdated
<artifactId>spotbugs-maven-plugin</artifactId>
<version>3.1.3</version>
<configuration>
<classFilesDirectory>${basedir}/target/scala-2.11/classes</classFilesDirectory>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may also want to apply it to 2.12 later?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, me too. Good catch.

@HyukjinKwon
Copy link
Member

Seems fine to me otherwise.

<configuration>
<classFilesDirectory>${basedir}/target/scala-2.11/classes</classFilesDirectory>
<testClassFilesDirectory>${basedir}/target/scala-2.11/test-classes</testClassFilesDirectory>
<effort>Max</effort>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kiszk, btw do you roughly know how much time this PR increases in the build?

Copy link
Member Author

@kiszk kiszk Jul 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see large difference of maven's user time with and w/o Max

with Max

user	17m18.628s

without Max

user	17m3.724s

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, how much does it increase the Maven build time by this whole PR then roughly?

@SparkQA
Copy link

SparkQA commented Jul 9, 2018

Test build #92746 has finished for PR 21542 at commit 6b747c3.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor

retest this please

@cloud-fan
Copy link
Contributor

cloud-fan commented Jul 9, 2018

LGTM, let's run test one more time to make sure it's not flaky

Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM too

But still it would be nicer if we know how much this PR one increases the total build time as well roughly since we actually take care about the build time.

@SparkQA
Copy link

SparkQA commented Jul 9, 2018

Test build #92757 has finished for PR 21542 at commit 6b747c3.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@kiszk
Copy link
Member Author

kiszk commented Jul 9, 2018

retest this please

@kiszk
Copy link
Member Author

kiszk commented Jul 9, 2018

Does it make sense to compare these execution times thisPR and master

thisPR

4h20min building on an executor;

master

4h5min building on an executor;

@SparkQA
Copy link

SparkQA commented Jul 9, 2018

Test build #92767 has finished for PR 21542 at commit 6b747c3.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@viirya
Copy link
Member

viirya commented Jul 9, 2018

LGTM too.

@HyukjinKwon
Copy link
Member

Thank you so much @kiszk.

@cloud-fan
Copy link
Contributor

sorry missed this thread...

Let me trigger test again to make sure new code merged during these 2 days do not violate the check.

jenkins retest this please

@cloud-fan
Copy link
Contributor

retest this please

@SparkQA
Copy link

SparkQA commented Jul 11, 2018

Test build #92865 has finished for PR 21542 at commit 6b747c3.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@HyukjinKwon
Copy link
Member

Merged to master.

@asfgit asfgit closed this in 5ad4735 Jul 12, 2018
@skonto
Copy link
Contributor

skonto commented Jul 17, 2018

@HyukjinKwon @kiszk I see errors when I build locally on my machine:

[ERROR] Failed to execute goal com.github.spotbugs:spotbugs-maven-plugin:3.1.3:spotbugs (spotbugs) on project spark-network-common_2.11: Execution spotbugs of goal com.github.spotbugs:spotbugs-maven-plugin:3.1.3:spotbugs failed: Timeout: killed the sub-process -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :spark-network-common_2.11
org.apache.tools.ant.ExitException: Permission ("java.lang.RuntimePermission" "exitVM") was not granted.
	at org.apache.tools.ant.types.Permissions$MySM.checkExit(Permissions.java:194)
	at java.lang.Runtime.exit(Runtime.java:107)
	at java.lang.System.exit(System.java:971)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:358)
Exception in thread "main" org.apache.tools.ant.ExitException: Permission ("java.lang.RuntimePermission" "exitVM") was not granted.
	at org.apache.tools.ant.types.Permissions$MySM.checkExit(Permissions.java:194)
	at java.lang.Runtime.exit(Runtime.java:107)

@cloud-fan
Copy link
Contributor

have you cleaned your environment? How exactly did you build Spark locally?

@felixcheung
Copy link
Member

"permission" stuff might be Java 9 related?

@HyukjinKwon
Copy link
Member

Hmmmm this happened to me too and I just pushed fc2e189. Mine was Java 8. There's reproducer in the PR description.

@HyukjinKwon
Copy link
Member

This was reverted in favour of #21865 and SPARK-24895 for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants