Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Problem with debugging in Qt Creator when library contains thread_local

Problem with debugging in Qt Creator when library contains thread_local

Scheduled Pinned Locked Moved Installation and Deployment
1 Posts 1 Posters 597 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mikek_dk
    wrote on last edited by
    #1

    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 = subdirs

    SUBDIRS +=
    lib
    app@

    app.pro:
    @

    Turn on C++11 support

    QMAKE_CXXFLAGS = -std=c++11
    CONFIG += c++11

    Turn on thread support

    LIBS += -pthread

    QT += core

    QT -= gui

    TARGET = app
    CONFIG += console
    CONFIG -= app_bundle

    TEMPLATE = app

    SOURCES += main.cpp

    unix:!macx: LIBS += -L$$OUT_PWD/../lib/ -llib

    INCLUDEPATH += $$PWD/../lib
    DEPENDPATH += $$PWD/../lib

    unix:!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++11

    Turn on thread support

    LIBS += -pthread

    QT -= gui

    TARGET = lib
    TEMPLATE = lib
    CONFIG += staticlib

    SOURCES += lib.cpp

    HEADERS += lib.h
    unix {
    target.path = /usr/lib
    INSTALLS += target
    }@

    lib.h:
    @#ifndef LIB_H
    #define LIB_H

    class 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.)

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved