Crash when calling class member function from non-member function

In my code I have a class Log with a member function Push. Somewhere else I call this class function with an instance pLog->Push from a non-class function.

void some_stuff()

Doing this causes a SIGSEGV:
enter image description here

void Log::Push(const char *b)
    std::lock_guard<std::mutex> lock(m_Mutex);
    m_Messages.push_back(b); // std::deque<std::string>

When removing the mutex, another crash is invoked at m_Messages.push_back(b).
After some research I found out that making the function some_stuff member of Log this crash does not occur.
I even tried this on another g++ version (4.9) and it still happens.

Source: linux

Leave a Reply