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

OverridableMethodInConstructorCheck: can't run regression on openjdk9 #572

Closed
rnveach opened this Issue May 12, 2017 · 6 comments

Comments

Projects
None yet
2 participants
@rnveach
Copy link
Contributor

rnveach commented May 12, 2017

Config:

<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
          "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
          "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">

<module name="Checker">
    <property name="charset" value="UTF-8"/>
    <property name="haltOnException" value="false"/>

    <!--
      this config is a copy of
      https://github.com/checkstyle/checkstyle/blob/master/config/checkstyle_sevntu_checks.xml
      with update to global severity=ignore to catch only exceptions and changed to full package names.

      Some other checks are commented out to speed up execution time.
    -->

    <property name="severity" value="ignore"/>

    <!-- All checks are from https://github.com/sevntu-checkstyle/sevntu.checkstyle project -->

	<!-- BeforeExecutionFileFilters is required for sources of java9 -->
    <module name="BeforeExecutionExclusionFileFilter">
        <property name="fileNamePattern" value="module\-info\.java$" />
    </module>

    <module name="TreeWalker">
        <module name="com.github.sevntu.checkstyle.checks.coding.OverridableMethodInConstructor">
            <property name="checkCloneMethod" value="true"/>
            <property name="checkReadObjectMethod" value="true"/>
            <property name="matchMethodsByArgCount" value="true"/>
        </module>
    </module>
</module>

Run:

Exception in thread "main" java.lang.Error: Error was thrown while processing /home/ricky/opensource/contribution/checkstyle-tester/src/main/java/src/java.base/share/classes/sun/net/www/protocol/jar/JarURLConnection.java
    at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:297)
    at com.puppycrawl.tools.checkstyle.Checker.process(Checker.java:211)
    at org.apache.maven.plugin.checkstyle.exec.DefaultCheckstyleExecutor.executeCheckstyle(DefaultCheckstyleExecutor.java:252)
    at org.apache.maven.plugin.checkstyle.AbstractCheckstyleReport.executeReport(AbstractCheckstyleReport.java:473)
    at org.apache.maven.plugin.checkstyle.CheckstyleReport.executeReport(CheckstyleReport.java:154)
    at org.apache.maven.reporting.AbstractMavenReport.generate(AbstractMavenReport.java:255)
    at org.apache.maven.plugins.site.ReportDocumentRenderer.renderDocument(ReportDocumentRenderer.java:219)
    at org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.renderModule(DefaultSiteRenderer.java:319)
    at org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.render(DefaultSiteRenderer.java:135)
    at org.apache.maven.plugins.site.SiteMojo.renderLocale(SiteMojo.java:175)
    at org.apache.maven.plugins.site.SiteMojo.execute(SiteMojo.java:138)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded
    at java.util.LinkedList.linkLast(LinkedList.java:142)
    at java.util.LinkedList.add(LinkedList.java:338)
    at com.github.sevntu.checkstyle.checks.coding.OverridableMethodInConstructorCheck.getBaseClasses(OverridableMethodInConstructorCheck.java:847)
    at com.github.sevntu.checkstyle.checks.coding.OverridableMethodInConstructorCheck.getMethodDef(OverridableMethodInConstructorCheck.java:503)
    at com.github.sevntu.checkstyle.checks.coding.OverridableMethodInConstructorCheck.getOverridables(OverridableMethodInConstructorCheck.java:347)
    at com.github.sevntu.checkstyle.checks.coding.OverridableMethodInConstructorCheck.logWarnings(OverridableMethodInConstructorCheck.java:311)
    at com.github.sevntu.checkstyle.checks.coding.OverridableMethodInConstructorCheck.visitToken(OverridableMethodInConstructorCheck.java:270)
    at com.puppycrawl.tools.checkstyle.TreeWalker.notifyVisit(TreeWalker.java:363)
    at com.puppycrawl.tools.checkstyle.TreeWalker.processIter(TreeWalker.java:500)
    at com.puppycrawl.tools.checkstyle.TreeWalker.walk(TreeWalker.java:305)
    at com.puppycrawl.tools.checkstyle.TreeWalker.processFiltered(TreeWalker.java:180)
    at com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck.process(AbstractFileSetCheck.java:78)
    at com.puppycrawl.tools.checkstyle.Checker.processFile(Checker.java:314)
    at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:284)
    at com.puppycrawl.tools.checkstyle.Checker.process(Checker.java:211)
    at org.apache.maven.plugin.checkstyle.exec.DefaultCheckstyleExecutor.executeCheckstyle(DefaultCheckstyleExecutor.java:252)
    at org.apache.maven.plugin.checkstyle.AbstractCheckstyleReport.executeReport(AbstractCheckstyleReport.java:473)
    at org.apache.maven.plugin.checkstyle.CheckstyleReport.executeReport(CheckstyleReport.java:154)
    at org.apache.maven.reporting.AbstractMavenReport.generate(AbstractMavenReport.java:255)
    at org.apache.maven.plugins.site.ReportDocumentRenderer.renderDocument(ReportDocumentRenderer.java:219)
    at org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.renderModule(DefaultSiteRenderer.java:319)
    at org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.render(DefaultSiteRenderer.java:135)
    at org.apache.maven.plugins.site.SiteMojo.renderLocale(SiteMojo.java:175)
    at org.apache.maven.plugins.site.SiteMojo.execute(SiteMojo.java:138)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)

I give regression 4 gigs of memory.

@rnveach

This comment has been minimized.

Copy link
Contributor

rnveach commented Jun 8, 2018

Error is still happening even without maven, but this time it was a different file. There must be some issue in the check, I will have to look closer at the code.

Exception in thread "main" java.lang.Error: Error was thrown while processing /home/ricky/regression_repositories/openjdk9/src/jdk.httpserver/share/classes/sun/net/httpserver/SSLStreams.java
    at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:299)
    at com.puppycrawl.tools.checkstyle.Checker.process(Checker.java:213)
    at com.puppycrawl.tools.checkstyle.Main.runCheckstyle(Main.java:554)
    at com.puppycrawl.tools.checkstyle.Main.runCli(Main.java:465)
    at com.puppycrawl.tools.checkstyle.Main.main(Main.java:219)
Caused by: java.lang.OutOfMemoryError: Java heap space
    at java.util.LinkedList.linkLast(LinkedList.java:142)
    at java.util.LinkedList.add(LinkedList.java:338)
    at com.github.sevntu.checkstyle.checks.coding.OverridableMethodInConstructorCheck.getBaseClasses(OverridableMethodInConstructorCheck.java:837)
    at com.github.sevntu.checkstyle.checks.coding.OverridableMethodInConstructorCheck.getMethodDef(OverridableMethodInConstructorCheck.java:502)
    at com.github.sevntu.checkstyle.checks.coding.OverridableMethodInConstructorCheck.getOverridables(OverridableMethodInConstructorCheck.java:353)
    at com.github.sevntu.checkstyle.checks.coding.OverridableMethodInConstructorCheck.logWarnings(OverridableMethodInConstructorCheck.java:318)
    at com.github.sevntu.checkstyle.checks.coding.OverridableMethodInConstructorCheck.visitToken(OverridableMethodInConstructorCheck.java:278)
    at com.puppycrawl.tools.checkstyle.TreeWalker.notifyVisit(TreeWalker.java:389)
    at com.puppycrawl.tools.checkstyle.TreeWalker.processIter(TreeWalker.java:500)
    at com.puppycrawl.tools.checkstyle.TreeWalker.walk(TreeWalker.java:329)
    at com.puppycrawl.tools.checkstyle.TreeWalker.processFiltered(TreeWalker.java:182)
    at com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck.process(AbstractFileSetCheck.java:81)
    at com.puppycrawl.tools.checkstyle.Checker.processFile(Checker.java:316)
    at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:286)
    ... 4 more

Without maven, execution kept going for other projects and some threw the same exception.

@rnveach

This comment has been minimized.

Copy link
Contributor

rnveach commented Jun 8, 2018

openjdk9/src/jdk.httpserver/share/classes/sun/net/httpserver/SSLStreams.java

I can reproduce the issue.


classDefNode = CLASS_DEF[494x4]
baseClassName = InputStream
curClass = CLASS_DEF[494x4]

We are stuck in an infinite loop because the code is creating a class that extends another class of a similar name.

class InputStream extends java.io.InputStream {

This causes result to keep populating with the same class over and over and causes the out of memory. If result wasn't a LinkedList but a Set the program would have never ended.

This shows the check isn't aware of it's package location as it thinks java.io.InputStream is the same as sun.net.httpserver.SSLStreams$InputStream.

@rnveach

This comment has been minimized.

Copy link
Contributor

rnveach commented Jun 8, 2018

Minimal test case is:

import java.io.IOException;

public class TestClass {
	class InputStream extends java.io.InputStream {
		InputStream() {
			method();
		}

		@Override
		public int read() throws IOException {
			return 0;
		}
	}

	public void method() {
	};
}
@romani

This comment has been minimized.

Copy link
Member

romani commented Jun 8, 2018

Please clean up issue to make it simply reproducible by CLI

@rnveach

This comment has been minimized.

Copy link
Contributor

rnveach commented Jun 8, 2018

The following projects cause the issue and can't be regressed on for a difference report:

openjdk10, openjdk9, openjdk7, openjdk8, apache-ant, apacheapex

rnveach added a commit to rnveach/sevntu.checkstyle that referenced this issue Jun 8, 2018

romani added a commit that referenced this issue Jun 8, 2018

@romani romani added this to the 1.30.0 milestone Jun 8, 2018

@romani

This comment has been minimized.

Copy link
Member

romani commented Jun 8, 2018

fix is merged

@romani romani closed this Jun 8, 2018

@rnveach rnveach added the bug label Jun 23, 2018

kariem added a commit to kariem/sevntu.checkstyle that referenced this issue Jul 26, 2018

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