Results 1 to 20 of 27

Thread: QT4.2 corrupted double-linked list and QRadioButton existance

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2007
    Location
    Warsaw, Poland
    Posts
    52
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QT4.2 corrupted double-linked list and QRadioButton existance

    Hi again,
    I have encountered an odd obstacle.
    I implement MVC pattern using subclassed QTreeView as myView and QAbstractItemModel as myModel. I place the myView object in MyMVC that contains combo box and line edit, which are used as filter input. Anyway, everything works perfect with the whole application.

    But when I add a few (commented below in mymvc.cpp) lines I get Core Dumped and the main window of my program just shows for a while and dissapears.

    Above the backtrace I receive:
    *** glibc detected *** ./PL09: corrupted double-linked list: 0x08124aa8 ***
    (PL09 is a name of a application file)

    Here is the code of mymvc.h
    Qt Code:
    1. #ifndef MTR_SAFETY_DECLARATION_FOR_MYMVC_H
    2. #define MTR_SAFETY_DECLARATION_FOR_MYMVC_H
    3. #include <QWidget>
    4. namespace MTR {
    5. class Book;
    6. class SBook;
    7. }
    8. class myView;
    9. class myModel;
    10. class QLabel;
    11. class QComboBox;
    12. class QLineEdit;
    13.  
    14. class MyMVC : public QWidget {
    15. Q_OBJECT
    16. public:
    17. MyMVC(QList<MTR::Book>* list = 0, QWidget* parent = 0);
    18. void prodModel(QList<MTR::Book>*);
    19. public slots:
    20. bool getCaseSensitive(void) { return caseSensitive; }
    21. void setCaseSensitive(bool cs) { caseSensitive = cs; }
    22. signals:
    23. void doubleClickInTreeView(int);
    24. private:
    25. QList<MTR::SBook>* slist;
    26. QLineEdit* le;
    27. QComboBox* qcb;
    28. myModel* model;
    29. myView* qtv;
    30. QLabel* label;
    31. bool caseSensitive;
    32. QRadioButton* radioOne;
    33. QRadioButton* radioTwo;
    34. };
    35.  
    36. #endif
    To copy to clipboard, switch view to plain text mode 

    Then you have mymvc.cpp
    Qt Code:
    1. #include "mymvc.h"
    2. #include "myView.h"
    3. #include "sbook.h"
    4. #include "myModel.h"
    5. #include "myHeaderView.h"
    6. #include <QList>
    7. #include <QGridLayout>
    8. #include <QLabel>
    9. #include <QLineEdit>
    10. #include <QComboBox>
    11. #include <QRadioButton>
    12.  
    13. MyMVC::MyMVC(QList<MTR::Book>* list, QWidget* parent) {
    14. slist = new QList<MTR::SBook>();
    15. for(int i = 0;i<list->size();++i) {
    16. slist->append(MTR::SBook(i,list->value(i)));
    17. }
    18. setFixedSize(590,400);
    19.  
    20. le = new QLineEdit();
    21. qcb = new QComboBox();
    22. qcb->addItem(tr("filter by Title"));
    23. qcb->addItem(tr("filter by Author"));
    24. qcb->addItem(tr("filter by Publisher"));
    25. qcb->setCurrentIndex(0);
    26.  
    27. model = new myModel(*slist,le,qcb);
    28. model->filter();
    29.  
    30. qtv = new myView(model);
    31. qtv->header()->setSortIndicator(0,Qt::DescendingOrder);
    32.  
    33. label = new QLabel(tr("Enter a character string below"));
    34. //radioOne = new QRadioButton(tr("Case Sensitive - TRUE"));
    35. //radioTwo = new QRadioButton(tr("Case Sensitive - FALSE"));
    36. //radioOne->setChecked(true);
    37. caseSensitive = true;
    38. qvb = new QGridLayout();
    39. //connect(radioOne,SIGNAL(toggled(bool)),this,SLOT(setCaseSensitive(bool)));
    40. connect(qcb,SIGNAL(currentIndexChanged(int)),le,SLOT(clear()));
    41. connect(qcb,SIGNAL(currentIndexChanged(int)),qtv,SLOT(filter()));
    42. connect(le,SIGNAL(textChanged(const QString &)),qtv,SLOT(filter()));
    43. connect(model,SIGNAL(fromTVtoVM(int)),this,SIGNAL(doubleClickInTreeView(int)));
    44.  
    45. qvb->addWidget(label,0,0);
    46. //qvb->addWidget(radioOne,0,1);
    47. qvb->addWidget(le,1,0);
    48. //qvb->addWidget(radioTwo,1,1);
    49. qvb->addWidget(qcb,2,0,1,2);
    50. qvb->addWidget(qtv,3,0,1,2);
    51. setLayout(qvb);
    52. }
    53.  
    54. void MyMVC::prodModel(QList<MTR::Book>* list) {
    55. slist->clear();
    56. for(int i = 0;i<list->size();++i) {
    57. slist->append(MTR::SBook(i,list->value(i)));
    58. }
    59. model->setInternalList(*slist);
    60. qcb->setCurrentIndex(0);
    61. qtv->filter();
    62.  
    63. }
    To copy to clipboard, switch view to plain text mode 

    So my question is simple: what is going on... ?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    Could you paste backtrace from debugger?
    J-P Nurmi

  3. #3
    Join Date
    May 2007
    Location
    Warsaw, Poland
    Posts
    52
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    Aye, here you have:
    Qt Code:
    1. ======= Backtrace: =========
    2. /lib/tls/i686/cmov/libc.so.6[0xb72a6ceb]
    3. /lib/tls/i686/cmov/libc.so.6[0xb72a8ecd]
    4. /lib/tls/i686/cmov/libc.so.6(malloc+0x7f)[0xb72aa83f]
    5. /lib/tls/i686/cmov/libc.so.6[0xb7258c79]
    6. /lib/tls/i686/cmov/libc.so.6(iconv_open+0x1aa)[0xb725870a]
    7. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4[0xb7656094]
    8. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4[0xb76568d7]
    9. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN7QString13fromLocal8BitEPKci+0x6a)[0xb75b395a]
    10. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN16QCoreApplication9argumentsEv+0x73)[0xb762a2e3]
    11. /usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4[0xb79fae7d]
    12. /usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4[0xb79fbad6]
    13. /usr/lib/libSM.so.6(_SmcProcessMessage+0xe3c)[0xb7876924]
    14. /usr/lib/libICE.so.6(IceProcessMessages+0x3c0)[0xb78694c6]
    15. /usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4[0xb79f48f8]
    16. /usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4[0xb79f4977]
    17. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN11QMetaObject8activateEP7QObjectiiPPv+0x688)[0xb7639908]
    18. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN11QMetaObject8activateEP7QObjectPKS_iPPv+0x3a)[0xb763a28a]
    19. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN15QSocketNotifier9activatedEi+0x43)[0xb7658f03]
    20. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN15QSocketNotifier5eventEP6QEvent+0x24f)[0xb76409af]
    21. /usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4(_ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent+0x180)[0xb79a7230]
    22. /usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4(_ZN12QApplication6notifyEP7QObjectP6QEvent+0x111)[0xb79a9961]
    23. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4[0xb764b51f]
    24. /usr/lib/libglib-2.0.so.0(g_main_context_dispatch+0x182)[0xb74c9802]
    25. /usr/lib/libglib-2.0.so.0[0xb74cc7df]
    26. /usr/lib/libglib-2.0.so.0(g_main_context_iteration+0x65)[0xb74ccd45]
    27. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN20QEventDispatcherGlib13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE+0x58)[0xb764ba68]
    28. /usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4[0xb7a26595]
    29. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN10QEventLoop13processEventsE6QFlagsINS_17ProcessEventsFlagEE+0x31)[0xb76272e1]
    30. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE+0x7a)[0xb76273ea]
    31. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN16QCoreApplication4execEv+0xa8)[0xb76297e8]
    32. /usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4(_ZN12QApplication4execEv+0x27)[0xb79a6cf7]
    33. ./PL09[0x80527ac]
    34. /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xdc)[0xb72578cc]
    35. ./PL09(_ZN6QFrame10paintEventEP11QPaintEvent+0x31)[0x8051311]
    36. ======= Memory map: ========
    37. (...)
    38. Aborted (core dumped)
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    May 2007
    Location
    Warsaw, Poland
    Posts
    52
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    and gdb backtrace:
    Qt Code:
    1. (gdb) backtrace
    2. #0 0xffffe410 in __kernel_vsyscall ()
    3. #1 0xb72ab770 in raise () from /lib/tls/i686/cmov/libc.so.6
    4. #2 0xb72acef3 in abort () from /lib/tls/i686/cmov/libc.so.6
    5. #3 0xb72e0d0b in __fsetlocking () from /lib/tls/i686/cmov/libc.so.6
    6. #4 0xb72e6ceb in malloc_usable_size () from /lib/tls/i686/cmov/libc.so.6
    7. #5 0xb72e8ecd in free () from /lib/tls/i686/cmov/libc.so.6
    8. #6 0xb72ea83f in malloc () from /lib/tls/i686/cmov/libc.so.6
    9. #7 0xb7298c79 in iconv_close () from /lib/tls/i686/cmov/libc.so.6
    10. #8 0xb729870a in iconv_open () from /lib/tls/i686/cmov/libc.so.6
    11. #9 0xb7696094 in QIconvCodec::createIconv_t (to=0xb76c0ced "UTF-16",
    12. from=0x6 <Address 0x6 out of bounds>) at codecs/qiconvcodec.cpp:227
    13. #10 0xb76968d7 in QIconvCodec::convertToUnicode (this=0x80a7260,
    14. chars=0xbf84a823 "/home/mtr/Programowanie/Projekty/PersonalLibrarianProject/PL09", len=62) at codecs/qiconvcodec.cpp:68
    15. #11 0xb75f395a in QString::fromLocal8Bit (
    16. str=0xbf84a823 "/home/mtr/Programowanie/Projekty/PersonalLibrarianProject/PL09", size=62) at ../../include/QtCore/../../src/corelib/codecs/qtextcodec.h:94
    17. #12 0xb766a2e3 in QCoreApplication::arguments ()
    18. at kernel/qcoreapplication.cpp:1621
    19. #13 0xb7a3ae7d in sm_performSaveYourself (smd=0x81089a0)
    20. at kernel/qapplication_x11.cpp:4711
    21. #14 0xb7a3bad6 in sm_saveYourselfCallback (smcConn=0x8107fc0,
    22. clientData=0x81089a0, saveType=1, shutdown=0, interactStyle=0)
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    Quote Originally Posted by mtrpoland View Post
    #9 0xb7696094 in QIconvCodec::createIconv_t (to=0xb76c0ced "UTF-16",
    from=0x6 <Address 0x6 out of bounds>) at codecs/qiconvcodec.cpp:227
    #10 0xb76968d7 in QIconvCodec::convertToUnicode (this=0x80a7260, chars=0xbf84a823 "/home/mtr/Programowanie/Projekty/PersonalLibrarianProject/PL09", len=62) at codecs/qiconvcodec.cpp:68
    What is that QIconvCodec? What does convertToUnicode() pass as the from parameter to createIconv_t()? It seems that there's a null pointer somewhere.

  6. #6
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    I think the problem is in the setCaseSensitive slot.
    Could you post the code for it?

    EDIT: no, forget about that

  7. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    Quote Originally Posted by jacek View Post
    What is that QIconvCodec? What does convertToUnicode() pass as the from parameter to createIconv_t()? It seems that there's a null pointer somewhere.
    Internals of Qt:
    Qt Code:
    1. #if defined(Q_OS_HPUX)
    2. # define NO_BOM
    3. # define UTF16 "ucs2"
    4. #elif defined(Q_OS_AIX)
    5. # define NO_BOM
    6. # define UTF16 "UCS-2"
    7. #else
    8. # define UTF16 "UTF-16"
    9. #endif
    10.  
    11. ...
    12.  
    13. QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState *) const
    14. {
    15. if (utf16Codec == reinterpret_cast<QTextCodec *>(~0))
    16. return QString::fromAscii(chars, len);
    17.  
    18. iconv_t cd = createIconv_t(UTF16, 0); // <---
    19. ...
    20. }
    21.  
    22. ...
    23.  
    24. iconv_t QIconvCodec::createIconv_t(const char *to, const char *from)
    25. {
    26. Q_ASSERT((to == 0 && from != 0) || (to != 0 && from == 0));
    27.  
    28. iconv_t cd = (iconv_t) -1;
    29. #if defined(__GLIBC__) || defined(GNU_LIBICONV)
    30. // both GLIBC and libgnuiconv will use the locale's encoding if from or to is an empty string
    31. char *codeset = "";
    32. cd = iconv_open(to ? to : codeset, from ? from : codeset); // <---
    33. #else
    34. char *codeset = 0;
    35. #endif
    36. ...
    37. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    Quote Originally Posted by jpn View Post
    iconv_t cd = createIconv_t(UTF16, 0); // <---
    Quote Originally Posted by mtrpoland View Post
    to=0xb76c0ced "UTF-16", from=0x6 <Address 0x6 out of bounds>
    Something is fishy around here. Maybe the library was corrupted?

  9. #9
    Join Date
    Nov 2006
    Location
    Shrewsbury, UK
    Posts
    97
    Thanks
    3
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    Lets see if I undertstand this code.

    Qt Code:
    1. iconv_t cd = createIconv_t(UTF16, 0);
    To copy to clipboard, switch view to plain text mode 

    In reality your traceback implies you mean
    Qt Code:
    1. iconv_t cd = createIconv_t("UTF-16", NULL);
    To copy to clipboard, switch view to plain text mode 

    yet you get

    Qt Code:
    1. 0xb7696094 in QIconvCodec::createIconv_t (to=0xb76c0ced "UTF-16",
    2. from=0x6 <Address 0x6 out of bounds>) at codecs/qiconvcodec.cpp:227
    To copy to clipboard, switch view to plain text mode 

    Why do you get 0x6 then? I suggest you re-try using the NULL macro instead of 0.

    Pete

  10. #10
    Join Date
    May 2007
    Location
    Warsaw, Poland
    Posts
    52
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    So yo advise me to change the line:
    Qt Code:
    1. iconv_t cd = createIconv_t(UTF16, 0);
    To copy to clipboard, switch view to plain text mode 
    that is placed in some qt file
    to
    Qt Code:
    1. iconv_t cd = createIconv_t(UTF16, NULL);
    To copy to clipboard, switch view to plain text mode 
    ??
    Just don't get the idea why my actions that are actually a commonplace (initialization of two QRadioButton's and its usage) entail a problem I presented above.
    It's quite bizarre.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    Quote Originally Posted by mtrpoland View Post
    Just don't get the idea why my actions that are actually a commonplace (initialization of two QRadioButton's and its usage) entail a problem I presented above.
    It's quite bizarre.
    Yes, it is. Can you reproduce that stack trace?

  12. #12
    Join Date
    May 2007
    Location
    Warsaw, Poland
    Posts
    52
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    What do you mean by "reproducing the stack trace" ?

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    Quote Originally Posted by pdolbey View Post
    Why do you get 0x6 then? I suggest you re-try using the NULL macro instead of 0.
    The problematic code appears to be a part of Qt and it seems perfectly valid. Furthermore there's an assertion in QIconvCodec::createIconv_t() that should detect this situation.


    BTW. There is no such thing as NULL macro in C++, it's defined only for compatibility with C.

  14. #14
    Join Date
    Nov 2006
    Location
    Shrewsbury, UK
    Posts
    97
    Thanks
    3
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    Quote Originally Posted by jacek View Post
    BTW. There is no such thing as NULL macro in C++, it's defined only for compatibility with C.
    Apparently (and I've only just googled for this)

    The standard says that NULL exists, but is implementation-defined.

    Section 18.1, line 4 :

    "The macro NULL is an implementation-defined C + + null pointer constant
    in this International Standard (4.10)."

    It also mentions that it is defined in <cstddef>.

    Section 4.10 starts by defining a "null pointer constant" :

    "A null pointer constant is an integral constant expression (5.19)
    rvalue of integer type that evaluates to zero."


    In C++ NULL is typically either 0 or 0L (but not ((void*)0) - I was basically suggesting replacing 0 with NULL as I couldn't see any logical reason why the function call should transform '0' into '0x6' unless it was an compiler "implementation" gotcha. I'd always prefer NULL over 0 but thats because I think its more readable, but there seems to be many opinions on this matter.

    I didn't realise how deep this problem was in the Qt4 source code as I don't remember seeing the class QIconvCodec in the public API - just found it in the source tree.

    Pete
    Last edited by pdolbey; 19th July 2007 at 19:46. Reason: Question removed

  15. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    Quote Originally Posted by pdolbey View Post
    It also mentions that it is defined in <cstddef>.
    Exactly, as I said, it's only for compatibility with C. In the new C++ standard, there will be a nullptr constant, but for now the first paragraph in section 4.10 says: "A null pointer constant is an integral constant expression (5.19) rvalue of integer type that evaluates to zero."

    Quote Originally Posted by pdolbey View Post
    I couldn't see any logical reason why the function call should transform '0' into '0x6' unless it was an compiler "implementation" gotcha.
    It could be, but 0 is used as a null pointer in many places in Qt sources, so it shouldn't be a problem.

    Quote Originally Posted by pdolbey View Post
    I'd always prefer NULL over 0 but thats because I think its more readable, but there seems to be many opinions on this matter.
    It also causes some problems with templates.

    Quote Originally Posted by pdolbey View Post
    I don't remember seeing the class QIconvCodec in the public API
    Neither did I. You can learn new things about Qt every day.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.