facebook / infer

A static analyzer for Java, C, C++, and Objective-C
http://fbinfer.com/
MIT License
14.9k stars 2.01k forks source link

infer -a checkers --eradicate -- mvn clean compile failed? #1634

Open zhaoyangyingmu opened 2 years ago

zhaoyangyingmu commented 2 years ago

Hello, sorry to interrupt. I try to use infer to analyze my mvn project. When I run mvn clean compile, everything is fine. The info is like:

[INFO] Scanning for projects...
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.735 s
[INFO] Finished at: 2022-05-05T15:42:35+08:00
[INFO] ------------------------------------------------------------------------

But when I use infer -a checkers --eradicate -- mvn clean compile, it failed:

...
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ ToolAbilityComparison ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 15 source files to /home/user/xdf/ToolAbilityComparison/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.112 s
[INFO] Finished at: 2022-05-05T15:44:27+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project ToolAbilityComparison: Compilation failure -> [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/MojoFailureException
Usage Error: *** Maven command failed:
*** mvn clean compile -P infer-capture
*** exited with code 1

I see similar question in the issues, and I try the command without clean, but infer will not analyze the project when compiling is finished, right? So, how could I solve this problem? Here is my pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>ToolAbilityComparison</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>
    <dependencies>
<!--        cfnullness begin-->
        <dependency>
            <groupId>org.checkerframework</groupId>
            <artifactId>checker-qual</artifactId>
            <version>2.3.2</version>
        </dependency>
        <dependency>
            <groupId>org.checkerframework</groupId>
            <artifactId>checker</artifactId>
            <version>2.3.2</version>
        </dependency>
        <dependency>
            <groupId>org.checkerframework</groupId>
            <artifactId>jdk8</artifactId>
            <version>2.3.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.10.1</version>
        </dependency>
<!--        cfnullness end-->

    </dependencies>

    <build>
        <plugins>
<!--            cfnullness begin-->
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.10.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerArguments>
                        <Xmaxerrs>10000</Xmaxerrs>
                        <Xmaxwarns>10000</Xmaxwarns>
                    </compilerArguments>
                    <annotationProcessors>
                        <annotationProcessor>
                            org.checkerframework.checker.nullness.NullnessChecker
                        </annotationProcessor>
                        <annotationProcessor>
                            org.checkerframework.checker.interning.InterningChecker
                        </annotationProcessor>
                        <annotationProcessor>
                            org.checkerframework.checker.fenum.FenumChecker
                        </annotationProcessor>
                        <annotationProcessor>
                            org.checkerframework.checker.formatter.FormatterChecker
                        </annotationProcessor>
                    </annotationProcessors>
                    <compilerArgs>
                        <arg>-AprintErrorStack</arg>
                        <arg>-Awarns</arg>
                    </compilerArgs>
                </configuration>
            </plugin>
<!--            cfnullness end-->
        </plugins>
    </build>
</project>
mardukbp commented 2 years ago

Are you using JDK 11 or 8? I could not make it work with JDK 11, but with JDK 8 it worked.

Matyi98 commented 1 year ago

Hi, It's not a proper solution, but in my case helped:

/usr/local/bin$ sudo rm infer 
/usr/local/bin$ VERSION=1.0.0; curl -sSL "https://github.com/facebook/infer/releases/download/v$VERSION/infer-linux64-v$VERSION.tar.xz" | sudo tar -C /opt -xJ && sudo ln -s "/opt/infer-linux64-v$VERSION/bin/infer" /usr/local/bin/infer
/usr/local/bin$ infer --version
Infer version v1.0.0

So I downgraded Infer version from v1.1.0 to v1.0.0 Maven: 3.8.6, JDK11, Ubuntu 22.04 LTS