Menu

Porting cppcheck to AmigaOS 4

2022-07-28
2022-09-21
  • George Sokianos

    George Sokianos - 2022-07-28

    Hello everyone,
    The last few days I am working on porting cppcheck to AmigaOS 4. If you are not aware of it, is an operating system that works on very specific PowerPC based hardware and has its roots back to the AmigaOS that was first released in 1985. It is an exotic system and we have a small community of people using it. We are a few developers creating software for it and a tool like cppcheck would be great to have.

    I am using gcc 8 and I have managed to compile it and having it working pretty well, except one thing, were I need your help, if you are available of course. I am not familiar with cppcheck source code and I need some guidance.

    The problem I am experiencing is that cppcheck crashes when it exits. Even if I execute just the binary with no arguments, it prints out all the help information and then crashes. I tested it with a simple check in a src folder, it prints out all the findings just fine, and then at the end crashes.

    I used gstabs to get more info and understand where it crashes and that pointed to stl_list.h which can be seen at https://gcc.gnu.org/onlinedocs/gcc-4.7.2/libstdc++/api/a01472_source.html line 156. This seems it is called from check.cpp and check64bit.cpp.

    I tried with both source code from v2.8 release and the latest master branch from your git repo. Both behave the same way. On that I would like to ask if master branch should be trusted or it is better to work with the code from releases?

    I wonder if you could guide me on what cppcheck does when it exits and what to check, so to find the problem and try to fix it.

    Thank you so much for your help.

     
  • Daniel Marjamäki

    AmigaOS 4 that is cool stuff! :-)

    hmm so it crashes in std::list::iterator::operator++ during shutdown. I am not sure what iterators are used during shutdown.
    But if you run cppcheck in the debugger it should stop when it crashes and you should be able to see the backtrace. doesn't that work?

    gdb cppcheck
    r
    <Crash!>
    bt
    

    can you see if the exec.check(argc, argv); finish successfully?
    https://github.com/danmar/cppcheck/blob/main/cli/main.cpp#L111

     

    Last edit: Daniel Marjamäki 2022-07-28
  • Daniel Marjamäki

    On that I would like to ask if master branch should be trusted or it is better to work with the code from releases?

    I think master is better. it's not supposed to crash.

     
  • George Sokianos

    George Sokianos - 2022-07-28
    Post awaiting moderation.
  • Daniel Marjamäki

    In lib/check.cpp we have this code:

    std::list<Check *> &Check::instances()
    {
    #ifdef __SVR4
        // Under Solaris, destructors are called in wrong order which causes a segmentation fault.
        // This fix ensures pointer remains valid and reachable until program terminates.
        static std::list<Check *> *_instances= new std::list<Check *>;
        return *_instances;
    #else
        static std::list<Check *> _instances;
        return _instances;
    #endif
    }
    

    Could you check what happens if you run the solaris code in amiga. maybe the destructors are called in the wrong order.

     
  • George Sokianos

    George Sokianos - 2022-07-28

    Yes.... that was it. You are a star @danielmarjamaki
    This seems did the trick and now it doesn't crash.
    Thank you so much for that.

     
    • Daniel Marjamäki

      thanks I am not told I am a star often :-)

      do you have time to make a github PR?

       
  • George Sokianos

    George Sokianos - 2022-07-28

    I would be glad to do it. And already have all my changes using pre-processor if statements. So they won't break anything of your CI.

    But first I need to make sure it works well, and also compile it with rules. For that it requires pcre or pcre2?

    Thank you again for your valuable help.

     
    • orbitcowboy

      orbitcowboy - 2022-09-21

      Cppcheck uses pcre currently.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.