Problem with debugging in Qt Creator when library contains thread_local
-
Hi,
I have an issue that I hope someone can help with. I'm building a multithreaded application, using C++11 thread_local to get thread specific memory. My problem is that when I use a statically linked library and this library uses thread_locale, then I get a "SIGSEGV" (Segmentation fault) when ever I try to single step with the debugger over the statement that has the thread_local. (If just run the program, or move the code out of the lib then all seems fine).
I have simplified the progam to the following:
main.pro:
@TEMPLATE = subdirsSUBDIRS +=
lib
app@app.pro:
@Turn on C++11 support
QMAKE_CXXFLAGS = -std=c++11
CONFIG += c++11Turn on thread support
LIBS += -pthread
QT += core
QT -= gui
TARGET = app
CONFIG += console
CONFIG -= app_bundleTEMPLATE = app
SOURCES += main.cpp
unix:!macx: LIBS += -L$$OUT_PWD/../lib/ -llib
INCLUDEPATH += $$PWD/../lib
DEPENDPATH += $$PWD/../libunix:!macx: PRE_TARGETDEPS += $$OUT_PWD/../lib/liblib.a@
main.cpp:
@#include <QCoreApplication>#include "lib.h"
int main(int argc, char *argv[])
{QCoreApplication a(argc, argv);
Lib lib;return a.exec();
}@lib.pro:
@# Turn on C++11 support
QMAKE_CXXFLAGS = -std=c++11
CONFIG += c++11Turn on thread support
LIBS += -pthread
QT -= gui
TARGET = lib
TEMPLATE = lib
CONFIG += staticlibSOURCES += lib.cpp
HEADERS += lib.h
unix {
target.path = /usr/lib
INSTALLS += target
}@lib.h:
@#ifndef LIB_H
#define LIB_Hclass Lib
{public:
Lib();
};#endif // LIB_H@
@#include "lib.h"
Lib::Lib()
{
static thread_local int i;i++; // << When single stepping, this line crashes the program
}@I'm guessing there is something basic that I'm missing?
(Qt Creator 3.3.0, with QT 5.4.0, running Ubuntu 14.04 LTS.)