-
Notifications
You must be signed in to change notification settings - Fork 360
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
java.lang.NullPointerException in AbstractCxxPublicApiVisitor.visitTemplateDeclaration #2180
Comments
Hi @Nekto89, thanks for your feedback. The interesting part seems to be:
sonar-cxx/cxx-squid/src/main/java/org/sonar/cxx/visitors/AbstractCxxPublicApiVisitor.java Line 655 in c59843e
var declId = templateDeclaration.getFirstDescendant(CxxGrammarImpl.declaratorId);
if (declId == null) {
return;
}
var idNode = declId.getLastChild(qualifiedId);
if (idNode != null) {
idNode = idNode.getLastChild(IDENTIFIER);
} else {
idNode = declId;
}
String id = idNode.getTokenValue(); There seems to be a problem with a template declaration. Because the SSLR toolkit does not use the Public API visitor you don't get it there. Could you provide the template declaration creating the crash?
Regards, |
It seems to be caused by destructor
|
- NPE in case of unqualifiedid - improved error message: create id from declaratorId token stream (instead of IDENTIFIER only) - closd SonarOpenCommunity#2180
Hi @Nekto89, please try with snapshot after merge of #2182 is finished https://ci.appveyor.com/project/SonarOpenCommunity/sonar-cxx/branch/master/artifacts |
@guwirth crash is gone, thanks |
Describe the bug
SonarScanner fails to import source file because of java.lang.NullPointerException. Analysis of same file through cxx-sslr-toolkit-2.0.2.2734.jar works without problems.
To Reproduce
Sadly I can't share this code. Also I'm not sure how to minimize it if sslr-toolkit doesn't crash. I've tried copying defines and includes but it doesn't change anything.
Desktop (please complete the following information):
Additional context
12:42:30.504 ERROR: Error during SonarScanner execution
org.sonar.cxx.squidbridge.api.AnalysisException: Unable to parse file: ....hxx
at org.sonar.cxx.squidbridge.AstScanner.scanInputFiles(AstScanner.java:134)
at org.sonar.plugins.cxx.CxxSquidSensor.execute(CxxSquidSensor.java:299)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
at org.sonar.scanner.sensor.ProjectSensorsExecutor.execute(ProjectSensorsExecutor.java:49)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:360)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:150)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.lang.NullPointerException
at org.sonar.cxx.visitors.AbstractCxxPublicApiVisitor.visitTemplateDeclaration(AbstractCxxPublicApiVisitor.java:655)
at org.sonar.cxx.visitors.AbstractCxxPublicApiVisitor.visitDeclarator(AbstractCxxPublicApiVisitor.java:527)
at org.sonar.cxx.visitors.AbstractCxxPublicApiVisitor.visitSingleDeclarator(AbstractCxxPublicApiVisitor.java:519)
at org.sonar.cxx.visitors.AbstractCxxPublicApiVisitor.visitDeclaratorList(AbstractCxxPublicApiVisitor.java:473)
at org.sonar.cxx.visitors.AbstractCxxPublicApiVisitor.visitNode(AbstractCxxPublicApiVisitor.java:410)
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.walkAndVisit(AstWalker.java:69)
at org.sonar.cxx.squidbridge.AstScanner.walkAndVisit(AstScanner.java:155)
at org.sonar.cxx.squidbridge.AstScanner.scanInputFiles(AstScanner.java:132)
... 23 more
The text was updated successfully, but these errors were encountered: