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 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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
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.staticstd::list<Check*>*_instances=newstd::list<Check*>;return*_instances;#elsestaticstd::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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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?
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
I think master is better. it's not supposed to crash.
In lib/check.cpp we have this code:
Could you check what happens if you run the solaris code in amiga. maybe the destructors are called in the wrong order.
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.
thanks I am not told I am a star often :-)
do you have time to make a github PR?
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.
Cppcheck uses pcre currently.