1
votes

We developed a dynamic library L.so and an executable X which uses it. Both compiled with debugging info. While running gdb X:

Reading symbols from X...Segmentation fault (core dumped)

The X contains from 4 objects and I found out which one causes the crash. Lets say, if S.cpp is compiled, it crashes in gdb. S.cpp:

class Service { private: ... private: ... LongTaskService longTaskService_; // Implementation is in L.so

If I remove this method from S.cpp, the crash disappears:

bool Service::downloadFile(const string &mapName, int &taskId) {
   Properties dProps;
   if(!config_.get("downloadService", dProps)) {
     LOGG(Logger::ERROR) << "Failed to get config props for downloadService" << Logger::FLUSH;
     return false;
   }
   string url = dProps.get("downloadUrl");
   if(url == "") {
       LOGG(Logger::ERROR) << "Failed to get url for downloadService" << Logger::FLUSH;
       return false;
   }
   if(url[url.size()-1] != "/")
       url += "/";

   LOGG(Logger::DEBUG) << "Initializing download from "<< url << mapName << Logger::FLUSH;
   URL dUrl(url+mapName);
   vector<string> outPath = {workDir_, mapName};
   URL outFile(FsUtil::makePath(outPath));
   taskId = longTaskService_.submit(DownloadTask::run, dUrl, outFile); // This line causes problems 
   return true;
}

I wonder why is it like this and can I avoid the crash while debugging?

1
Have you tried loading it into another debugger e.g. lldb ? - Alexander Meißner

1 Answers

1
votes

The usual thing to do here is run "gdb gdb" and then file a bug report with the stack trace.

Another possibility is that you could try updating to a newer version of gdb. That might help.

Anyway it is just a bug. Very new versions of gdb have a bit of protection against some crashes of this sort; but protecting against all crashes is hard.