Skip to content
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

NullPointerException when analyzing source file #418

Closed
LegalizeAdulthood opened this issue Feb 3, 2015 · 11 comments · Fixed by #431
Closed

NullPointerException when analyzing source file #418

LegalizeAdulthood opened this issue Feb 3, 2015 · 11 comments · Fixed by #431
Labels
Milestone

Comments

@LegalizeAdulthood
Copy link

ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
        at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
        at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
        at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
        at org.sonar.runner.api.Runner.execute(Runner.java:100)
        at org.sonar.runner.Main.executeTask(Main.java:70)
        at org.sonar.runner.Main.execute(Main.java:59)
        at org.sonar.runner.Main.main(Main.java:53)
Caused by: org.sonar.squidbridge.api.AnalysisException: Unable to analyze file: D:\dev\bryce\src\Bryce\Plugins\RTGLibs\mrmgen\src\shared\Ijldefs.h
        at org.sonar.squidbridge.AstScanner.scanFiles(AstScanner.java:127)
        at org.sonar.plugins.cxx.squid.CxxSquidSensor.analyse(CxxSquidSensor.java:107)
        at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:79)
        at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:70)
        at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:119)
        at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:194)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
        at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:233)
        at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:228)
        at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:221)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
        at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:64)
        at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:51)
        at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:125)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
        at org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:173)
        at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
        at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
        ... 9 more
Caused by: java.lang.NullPointerException
        at org.sonar.cxx.visitors.AbstractCxxPublicApiVisitor.visitEnumSpecifier(AbstractCxxPublicApiVisitor.java:414)
        at org.sonar.cxx.visitors.AbstractCxxPublicApiVisitor.visitNode(AbstractCxxPublicApiVisitor.java:149)
        at com.sonar.sslr.impl.ast.AstWalker.visitNode(AstWalker.java:114)
        at com.sonar.sslr.impl.ast.AstWalker.visit(AstWalker.java:85)
        at com.sonar.sslr.impl.ast.AstWalker.visitChildren(AstWalker.java:99)
        at com.sonar.sslr.impl.ast.AstWalker.visit(AstWalker.java:87)
        at com.sonar.sslr.impl.ast.AstWalker.visitChildren(AstWalker.java:99)
        at com.sonar.sslr.impl.ast.AstWalker.visit(AstWalker.java:87)
        at com.sonar.sslr.impl.ast.AstWalker.visitChildren(AstWalker.java:99)
        at com.sonar.sslr.impl.ast.AstWalker.visit(AstWalker.java:87)
        at com.sonar.sslr.impl.ast.AstWalker.visitChildren(AstWalker.java:99)
        at com.sonar.sslr.impl.ast.AstWalker.visit(AstWalker.java:87)
        at com.sonar.sslr.impl.ast.AstWalker.visitChildren(AstWalker.java:99)
        at com.sonar.sslr.impl.ast.AstWalker.visit(AstWalker.java:87)
        at com.sonar.sslr.impl.ast.AstWalker.visitChildren(AstWalker.java:99)
        at com.sonar.sslr.impl.ast.AstWalker.visit(AstWalker.java:87)
        at com.sonar.sslr.impl.ast.AstWalker.visitChildren(AstWalker.java:99)
        at com.sonar.sslr.impl.ast.AstWalker.visit(AstWalker.java:87)
        at com.sonar.sslr.impl.ast.AstWalker.walkAndVisit(AstWalker.java:69)
        at org.sonar.squidbridge.AstScanner.scanFiles(AstScanner.java:106)
        ... 35 more
ERROR:
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.

Sonar claims my file is invalid, but the C++ compiler doesn't have any problems...

@LegalizeAdulthood
Copy link
Author

SonarQube 4.5.2
Plugin version 0.9.2

@wenns
Copy link
Contributor

wenns commented Feb 3, 2015

Thanks for the issue. Can you provide the code snippet which causes this?
@lcintrat: Can you have a look, please?

@LegalizeAdulthood
Copy link
Author

It's a closed source project, so I will have to ask about sharing code. They may say yes.

@guwirth
Copy link
Collaborator

guwirth commented Feb 3, 2015

We need not the whole code, only a small snippet to reproduce the problem.

@guwirth guwirth added the bug label Feb 3, 2015
@LegalizeAdulthood
Copy link
Author

It's one of our "dustier decks", I'm not sure if a small snippet outside the context of the entire file will reproduce the problem.

@lcintrat
Copy link
Contributor

Oops I didn't see it. I will have a look.

@lcintrat
Copy link
Contributor

@LegalizeAdulthood can you confirm that the NPE happens with an anonymous enumeration, something like:

enum {};

@LegalizeAdulthood
Copy link
Author

How do I know which file was being processed when the exception occurs?

I tried with the following source code:

enum { };

This completed without error.

From the -X log on our full source, I think I am getting the NullPointerException in the file ijldefs.h which originates with the Intel JPEG library. However, I can't find source to this out on the net, so I suspect it is commercial 3rd party source and not open source. However, I did see that this file contains a bunch of enum declarations in the global namespace. They all create a typedef in this form:

typedef enum { /* possibly some enum values */ } FOO;

So I tried a small .cpp file with this sort of declaration in it, and I couldn't reproduce the crash there either.

@lcintrat
Copy link
Contributor

@LegalizeAdulthood Nice !
But the API documentation visitor parses only .h header files :)
However, I already committed a fix for the unnamed enum.

@LegalizeAdulthood
Copy link
Author

I can reproduce the problem with an anonymous enum in a header included by the .cpp.

Is there a way to turn off specific decorators from the sonar-project.properties file?

@lcintrat
Copy link
Contributor

Ok so you can give a try to #431. I think this is the same problem.

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

Successfully merging a pull request may close this issue.

4 participants