I am using g++ and mudflap. When I run my code, it aborts where mudflap complaining about a double free:
*** glibc detected *** /mydir/MYMain: double free or corruption (out): 0x0000000002127880 ***
If I run it in gdb, I can see where it aborts:
queue<string> logQueue;
void someThreadSpawnFunction() {
string str;
while(true) {
{
boost::scoped_lock sl( aMutex);
// thread wait for loqQueue to have item
str = logQueue.front(); // <--------------- Aborts here.
logQueue.pop();
}
//write out string
}
The question is: Am I using std::queue and strings incorrectly?
In other parts of the code, there will be something like:
string msg;
// processMessage -- some bit a of code with stripNull()
logQueue.push(msg);
The only funny thing I can find in processMessage is this function:
std::string Log::stripNull(const std::string &str, bool &gotNulls)
{
std::string retStr = str;
// strip any trailing NULLs
size_t rsltPos = retStr.find_first_of('\0', 0);
if (rsltPos != string::npos)
{
gotNulls = true;
retStr.resize(rsltPos);
}
return(retStr);
}
Is it possible mudflap may be complaining about the stripNull function?
Thanks.