Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

java.lang.NullPointerException: Could not initialize cppcheck for project lib-ltc  #98

Description

@vanvught
eclipse.buildId=4.13.0.I20190916-1045
java.version=1.8.0_171
java.vendor=Oracle Corporation
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=nl_NL
Framework arguments: -product org.eclipse.epp.package.cpp.product -keyring /Users/arjanvanvught/.eclipse_keyring
Command-line arguments: -os macosx -ws cocoa -arch x86_64 -product org.eclipse.epp.package.cpp.product -keyring /Users/arjanvanvught/.eclipse_keyring
com.googlecode.cppcheclipse.core
Error
Tue Oct 01 21:55:37 CEST 2019
Could not initialize cppcheck for project lib-ltc
java.lang.NullPointerException
at com.googlecode.cppcheclipse.ui.ToolchainSettings.getIncludes(ToolchainSettings.java:181)
at com.googlecode.cppcheclipse.ui.ToolchainSettings.getUserIncludes(ToolchainSettings.java:87)
at com.googlecode.cppcheclipse.core.Checker.<init>(Checker.java:80)
at com.googlecode.cppcheclipse.ui.Builder$ResourceVisitor.initChecker(Builder.java:164)
at com.googlecode.cppcheclipse.ui.Builder$ResourceVisitor.processFile(Builder.java:199)
at com.googlecode.cppcheclipse.ui.Builder$ResourceVisitor.visit(Builder.java:122)
at org.eclipse.core.internal.resources.Resource.lambda$1(Resource.java:117)
at org.eclipse.core.internal.resources.Resource.lambda$0(Resource.java:85)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:85)
at org.eclipse.core.internal.watson.ElementTreeIterator.iterate(ElementTreeIterator.java:135)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:94)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:55)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:117)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:105)
at com.googlecode.cppcheclipse.ui.Builder.processResource(Builder.java:306)
at com.googlecode.cppcheclipse.ui.commands.RunCodeAnalysis$RunCodeAnalysisJob.runResource(RunCodeAnalysis.java:26)
at com.googlecode.cppcheclipse.ui.commands.ResourceSelectionJob.run(ResourceSelectionJob.java:44)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)</init>

Activity

  1. AntonKrug commented on Oct 2, 2019

    @AntonKrug
    Collaborator

    Could you describe what you were doing and how to replicate it?

  2. vanvught commented on Oct 2, 2019

    @vanvught
    Author

    Using the latest Eclipse 2019-09 with the plug-in from the Marketplace, I get this exception every-time when I run the cppcheck from the source file (pull-down menu). I can reproduce it on Linux Ubuntu as well.

  3. AntonKrug commented on Oct 2, 2019

    @AntonKrug
    Collaborator

    You didn't specify what version of cpccheck. Try to use cppcheck v1.83

  4. AntonKrug commented on Oct 2, 2019

    @AntonKrug
    Collaborator

    Second experiment you can do is install different build of cppcheclipse, what happens when you install this variant of the plugin?
    com.googlecode.cppcheclipse.repository-1.1.1.v20190927-1540.zip

  5. vanvught commented on Oct 2, 2019

    @vanvught
    Author

    You didn't specify what version of cpccheck. Try to use cppcheck v1.83

    MacOS : Cppcheck 1.89
    Linux : Cppcheck 1.82 {latest from apt install}

  6. vanvught commented on Oct 2, 2019

    @vanvught
    Author

    Second experiment you can do is install different build of cppcheclipse, what happens when you install this variant of the plugin?
    com.googlecode.cppcheclipse.repository-1.1.1.v20190927-1540.zip

    Also an exception.

    eclipse.buildId=4.13.0.I20190916-1045
    java.version=1.8.0_171
    java.vendor=Oracle Corporation
    BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=nl_NL
    
    org.eclipse.core.runtime.CoreException: Could not initialize cppcheck for project lib-tcnet
    	at com.googlecode.cppcheclipse.ui.Builder$ResourceVisitor.initChecker(Builder.java:192)
    	at com.googlecode.cppcheclipse.ui.Builder$ResourceVisitor.processFile(Builder.java:199)
    	at com.googlecode.cppcheclipse.ui.Builder$ResourceVisitor.visit(Builder.java:122)
    	at org.eclipse.core.internal.resources.Resource.lambda$1(Resource.java:117)
    	at org.eclipse.core.internal.resources.Resource.lambda$0(Resource.java:85)
    	at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:85)
    	at org.eclipse.core.internal.watson.ElementTreeIterator.iterate(ElementTreeIterator.java:135)
    	at org.eclipse.core.internal.resources.Resource.accept(Resource.java:94)
    	at org.eclipse.core.internal.resources.Resource.accept(Resource.java:55)
    	at org.eclipse.core.internal.resources.Resource.accept(Resource.java:117)
    	at org.eclipse.core.internal.resources.Resource.accept(Resource.java:105)
    	at com.googlecode.cppcheclipse.ui.Builder.processResource(Builder.java:306)
    	at com.googlecode.cppcheclipse.ui.commands.RunCodeAnalysis$RunCodeAnalysisJob.runResource(RunCodeAnalysis.java:26)
    	at com.googlecode.cppcheclipse.ui.commands.ResourceSelectionJob.run(ResourceSelectionJob.java:44)
    	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
    Caused by: java.lang.NullPointerException
    	at com.googlecode.cppcheclipse.ui.ToolchainSettings.getIncludes(ToolchainSettings.java:182)
    	at com.googlecode.cppcheclipse.ui.ToolchainSettings.getUserIncludes(ToolchainSettings.java:88)
    	at com.googlecode.cppcheclipse.core.Checker.<init>(Checker.java:81)
    	at com.googlecode.cppcheclipse.ui.Builder$ResourceVisitor.initChecker(Builder.java:164)
    	... 14 more
    
  7. AntonKrug commented on Oct 4, 2019

    @AntonKrug
    Collaborator

    Can you share what source it is (it shouldn't matter), but still. Or can you export a project for me to try to replicate it?

    Do you have some CDT plugin on top of Eclipse when you do the C coding? Is the C project configured correctly (building as managed project, not some external makefile)?

  8. vanvught commented on Oct 4, 2019

    @vanvught
    Author

    Can you share what source it is (it shouldn't matter), but still. Or can you export a project for me to try to replicate it?

    https://github.com/vanvught/rpidmx512

    Do you have some CDT plugin on top of Eclipse when you do the C coding?

    Yes, CDT latest release.

    Is the C project configured correctly (building as managed project, not some external makefile)?

    All projects are correctly configured with using an external makefile.

  9. AntonKrug commented on Oct 4, 2019

    @AntonKrug
    Collaborator

    So then no, that's just external makefile project, The 'Managed' is CDT's term:
    https://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Fconcepts%2Fcdt_c_build_over.htm

    And CDT is not optional:
    https://github.com/kwin/cppcheclipse/wiki/Installation#requirements

    If you want to use marketplace version of the plugin then any cppcheck above v1.83 will not work even when you will have the project as a proper CDT project.

    If you really want just rogue makefiles then you can just run cppcheck from them, no need for this plugin.

  10. AntonKrug commented on Oct 4, 2019

    @AntonKrug
    Collaborator

    On top of CDT because your project is baremetal (cool project btw), you might want to use GNU MCU Eclipse plugin as well, if you have Olimex jtag then you should be able to do interactive debuging through the GME plugin (it helps orchestrating OpenOCD and configuring the right switches for the toolchain so then it generates correct makefiles for you)

  11. vanvught commented on Oct 4, 2019

    @vanvught
    Author

    And CDT is not optional:
    https://github.com/kwin/cppcheclipse/wiki/Installation#requirements

    I've got CDT (of course). I just corrected my comment.

  12. vanvught commented on Oct 4, 2019

    @vanvught
    Author

    If you really want just rogue makefiles then you can just run cppcheck from them, no need for this plugin.

    Advantage of a plug-in is that the output is referenced to the source code.

  13. vanvught commented on Oct 4, 2019

    @vanvught
    Author

    On top of CDT because your project is baremetal (cool project btw),

    Thanks!

    you might want to use GNU MCU Eclipse plugin as well, if you have Olimex jtag then you should be able to do interactive debuging through the GME plugin (it helps orchestrating OpenOCD and configuring the right switches for the toolchain so then it generates correct makefiles for you)

    I am not that eager with auto generated make files. I want to have full control on my own build process.

  14. AntonKrug commented on Oct 4, 2019

    @AntonKrug
    Collaborator

    I imported it into my Eclipse and run check on your lib-tcnet and I didn't got any exceptions, see attachment.
    cppcheck.txt

  15. vanvught commented on Oct 4, 2019

    @vanvught
    Author

    I really can't get it to work ;-(

    uname -a
    Darwin MacBook-Air.local 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64 x86_64
    cppcheck --version
    Cppcheck 1.89
    
    

    Schermafbeelding 2019-10-04 om 16 38 28

    Schermafbeelding 2019-10-04 om 16 41 05

  16. bernhard2020 commented on Jul 21, 2020

    @bernhard2020

    I had the same problem on some eclipse projects. Other projects worked just fine. The difference is, that the error occurs only in projects, where the source code is just linked to the eclipse workspace.
    Might this be the root cause of the problem? - A solution would be very appreciated!

  17. Mahdi-Hosseinali commented on Nov 6, 2020

    @Mahdi-Hosseinali

    I have a similar problem. I can run cppcheck fine on 3 out of 4 projects but it throws the following error for a single project:
    image

    The main difference between this project and the others is that I have a whole bunch of linked files in this project. Also, there are includes from other projects to avoid code duplication. Not sure which one is causing this null pointer.

    If I run cppcheck on a directory of this project does some checks (even though there are linked files in that directory) but complains that it cannot find all the includes (understandable) and the warnings are from the other project where the files are linked here! Not sure if the linked files are directing the cppcheck to the other project and it gets stuck there or not.

  18. Hanzel44 commented on Nov 23, 2020

    @Hanzel44

    @AntonKrug, Figured out it has to do with the 'Is a workspace path' checkmark of the includes. When I enable this with a 'basic' test.cpp file i will get the same kind of error. It seems it is cppcheck unrelated, because it does not even get to the point it executes cppcheck.

  19. AntonKrug commented on Nov 26, 2020

    @AntonKrug
    Collaborator

    @Hanzel44 thank you very much for the update. With eclipse there is so much which can go wrong

    @vanvught is yours issue workspace related as well, should we close this issue?

  20. Hanzel44 commented on Dec 9, 2020

    @Hanzel44

    @AntonKrug i mean it is not an issue of cppcheck.exe itself. It is an issue of the cppcheclipse plugin. So i ques it could only be closed if it is fixed.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions