Menu

Segmentation fault

2015-08-12
2015-08-13
  • Raistlin Majere

    Raistlin Majere - 2015-08-12

    Im just running cppcheck --enable=all with this code and I'm getting segfault

    #include "SBPAudioFileFormatChecker.h"
    #include "SBPAudioFileFormatCheckerBase.h"
    #include "SBPAudioFileFormatCheckerWav.h"
    #include "SBPAudioValidFormats.h"
    
    #include <map>
    #include <memory>
    
    ///! Private
    class basic_factory_file_format_checker {
    public:
      basic_factory_file_format_checker()
      {
        m_factory[WAV] = std::unique_ptr<base_file_format_checker>(new SBPAudioFileFormatCheckerWav());
      }
      /**
       * Factory with the list of file loaders
       * if not file is found we will return a nullptr
       */
      std::map<SBPAudioValidFormat, std::unique_ptr<base_file_format_checker>>
          m_factory;
    };
    static basic_factory_file_format_checker g_factory;
    ///! Private
    
    std::shared_ptr<SBPAudioFile>
    SBPAudioFileFormatLoader::Load(const std::string &filename) {
      if (filename.empty()) {
        return nullptr;
      }
      for(auto& element: g_factory.m_factory){
        if(element.second->checks(filename)){
    
        }
      }
    }
    

    This is the gdb output

    (gdb) bt
    #0  0x0000003e68ccf04d in std::string::compare(char const*) const () from /lib64/libstdc++.so.6
    #1  0x000000000050761e in UninitVar::parse(Token const&, std::list<ExecutionPath*, std::allocator<ExecutionPath*> >&) const ()
    #2  0x000000000052ad9d in ExecutionPath::checkScope(Token const*, std::list<ExecutionPath*, std::allocator<ExecutionPath*> >&) ()
    #3  0x000000000052bd5e in checkExecutionPaths(SymbolDatabase const*, ExecutionPath*) ()
    #4  0x00000000004fe6b9 in CheckUninitVar::executionPaths() ()
    #5  0x0000000000508f6a in CheckUninitVar::runSimplifiedChecks(Tokenizer const*, Settings const*, ErrorLogger*) ()
    #6  0x000000000051922a in CppCheck::checkFile(std::string const&, char const*, std::set<unsigned long long, std::less<unsigned long long>, std::allocator<unsigned long long> >&) ()
    #7  0x000000000051bf05 in CppCheck::processFile(std::string const&, std::istream&) ()
    #8  0x000000000051d7db in CppCheck::check(std::string const&) ()
    #9  0x0000000000443f8d in CppCheckExecutor::check_internal(CppCheck&, int, char const* const*) ()
    #10 0x0000000000444fef in CppCheckExecutor::check(int, char const* const*) ()
    #11 0x00000000004390f3 in main ()
    (gdb) 
    
     
  • Daniel Marjamäki

    Thanks! This segfault should be fixed already. This ExecutionPath stuff has been removed in latest git head. If you want, feel free to download the latest source code and verify that it works.

     

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.