Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8045037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:25:03+00:00 2026-06-05T05:25:03+00:00

I’m trying to create shared library (with CMake) which uses Qt objects (in particular

  • 0

I’m trying to create shared library (with CMake) which uses Qt objects (in particular QString and QQueue) inside and using this library with other application. The problem is that application recieves SIGSEGV when it calls methods of QQueue:

(gdb) r
Starting program: /home/ilya/projects/qtLogger/build/qtLoggerSample
[Thread debugging using libthread_db enabled]
startup
_DEBUG
QtLogger::QtLogger()
void QtLogger::foo(void*)
void QtLogger::log(QtLogger::LOG_LEVEL, QString) lvl: DEBUGmsg: "debug 1"

Program received signal SIGSEGV, Segmentation fault.
0x08049450 in QString (this=0x2817ad9c, other=...) at /usr/include/qt4/QtCore/qstring.h:714
714     inline QString::QString(const QString &other) : d(other.d)
(gdb) bt
#0  0x08049450 in QString (this=0x2817ad9c, other=...) at /usr/include/qt4/QtCore/qstring.h:714
#1  0xb7fdda0c in QList<QString>::node_construct (this=0x804b474, n=0x2817ad9c, t=...) at /usr/include/qt4/QtCore/qlist.h:352
#2  0xb7fdd7fa in QList<QString>::append (this=0x804b474, t=...) at /usr/include/qt4/QtCore/qlist.h:481
#3  0xb7fdd5e0 in QQueue<QString>::enqueue (this=0x804b474, t=...) at /usr/include/qt4/QtCore/qqueue.h:59
#4  0xb7fdd19f in QtLogger::log (this=0x804b460, level=QtLogger::LL_DEBUG, message=...)
    at /home/ilya/projects/qtLogger/lib-qtLogger/src/libqtlogger.cpp:97
#5  0x08049099 in main (argc=1, argv=0xbffff644) at    /home/ilya/projects/qtLogger/src/main.cpp:27

Source code of application can be found here: https://github.com/ilardm/qtLoggerSample/tree/137adee556f41eb4526e1d1c604e8541ef6eb65a

Source code of library can be found here(also available as git submodule of application repository): https://github.com/ilardm/lib-qtLogger/tree/bf1b490fd7c6666176c23e6fd791c00937d954b4

Could you please help me to understand where I’am wrong?

P.S. I’m using Qt 4.6.3, Debian Squeeze x86 and x64, gcc 4.4.5

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T05:25:05+00:00Added an answer on June 5, 2026 at 5:25 am

    You’re corrupting your QQueue with your initialization of the string array. For those who (like me) are having trouble navigating your Sources/Branches/SubRepositories…your declaration of QtLogger looks like this:

    class LIBQTLOGGER_EXPORT QtLogger
    {
    public:
        typedef enum {
            LL_EROR,
            LL_WARNING,
            LL_LOG,
            LL_DEBUG,
    
            LL_COUNT
        } LOG_LEVEL;
    
    public:
        QtLogger();
        ~QtLogger();
    
    public:
        void foo( void* );
    
        void log( LOG_LEVEL, QString );
    
    protected:
        LOG_LEVEL currentLevel;
        QString ll_string[ LL_COUNT ];
    
        QQueue< QString > messageQueue;
        QMutex mqMutex;
    };
    

    And then your constructor looks like this:

    QtLogger::QtLogger()
        : currentLevel( LL_DEBUG )
    {
    #if ENABLE_LOGGER_LOGGING
        std::clog << __PRETTY_FUNCTION__ << std::endl;
    #endif
    
        ll_string[ LL_EROR      ].sprintf( "ERROR" );
        ll_string[ LL_WARNING   ].sprintf( "WARN " );
        ll_string[ LL_LOG       ].sprintf( "LOG  " );
        ll_string[ LL_DEBUG     ].sprintf( "DEBUG" );
    
        ll_string[ LL_COUNT     ].sprintf( "     " );
    }
    

    LL_EROR is 0, LL_COUNT is 4. (Sidenote: That word is spelled “ERROR”, so your string is the correct bit.) Anyway…your declaration is effectively QString ll_string[4]; into which you are putting 5 strings and corrupting the subsequent member variable.

    Why you put that empty string in there in the first place is a bit of a mystery to me… (!) But either way, vector classes are pretty light weight in the scheme of things rather than raw arrays, and often provide more checking on bounds for common operations. Use QVector (or whatever) in the future and it will be easier to catch this class of bug:

    http://qt-project.org/doc/qt-4.8/qvector.html

    In short, this has nothing to do with shared-libraries. Next time, try building everything into a single executable before assuming that’s relevant! 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.