Results 1 to 5 of 5

Thread: *** glibc detected ***: free(): invalid pointer

  1. #1
    Join Date
    Apr 2007
    Posts
    76
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default *** glibc detected ***: free(): invalid pointer

    I've make an empty dialog with QtDesigner.

    then I've created a calss:
    myClass.h
    Qt Code:
    1. class myClass : public QWidget, private Ui::myForm
    2. {
    3. Q_OBJECT
    4. public:
    5. myClass(QWidget *parent=0);
    6. ~myClass();
    7. };
    To copy to clipboard, switch view to plain text mode 

    myClass.cpp
    Qt Code:
    1. myClass::myClass(QWidget *parent): QWidget(parent)
    2. {
    3. qDebug()<<"Initializing Form";
    4. setupUi((QDialog *)this);
    5. }
    6.  
    7. myClass::~myClass(){}
    To copy to clipboard, switch view to plain text mode 

    main.cpp
    Qt Code:
    1. int main( int argc, char **argv )
    2. {
    3. QApplication a( argc, argv );
    4. myClass *p = new myClass();
    5. //myClass p;
    6.  
    7. p->show();
    8. //p.show();
    9.  
    10. return a.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 

    after running the app it crash
    Initializing Form
    *** glibc detected *** ./jBox.x: free(): invalid pointer: 0x0000000000666ef0 ***
    ======= Backtrace: =========
    /lib64/libc.so.6[0x2b737c4914ba]
    /lib64/libc.so.6(cfree+0x8c)[0x2b737c49511c]
    /usr/lib64/qt-4.4.1/lib/libQtCore.so.4(_ZN23QCoreApplicationPrivate27remov ePostedEvents_unlockedEP7QObjectiP11QThreadData+0x 108)[0x2b737b1635e8]
    /usr/lib64/qt-4.4.1/lib/libQtCore.so.4(_ZN16QCoreApplication18removePosted EventsEP7QObjecti+0x93)[0x2b737b163963]
    /usr/lib64/qt-4.4.1/lib/libQtGui.so.4(_ZN7QWidgetD2Ev+0x15c)[0x2b7378e5d45c]
    ./jBox.x(_ZN8qJukeBoxD0Ev+0x2e)[0x403e20]
    /usr/lib64/qt-4.4.1/lib/libQtGui.so.4(_ZN7QDialog18setSizeGripEnabledEb+0x 56)[0x2b7379229ea6]
    ./jBox.x(_ZN9Ui_jbForm7setupUiEP7QDialog+0x159)[0x4048ab]
    ./jBox.x(_ZN8qJukeBoxC1EP7QWidget+0xc4)[0x403f82]
    ./jBox.x(main+0x42)[0x403c06]
    /lib64/libc.so.6(__libc_start_main+0xf4)[0x2b737c43e074]
    ./jBox.x(_ZNK7QWidget6metricEN12QPaintDevice17PaintD eviceMetricE+0xa1)[0x403a19]
    ======= Memory map: ========
    00400000-00406000 r-xp 00000000 08:0e 925727 jBox.x
    00605000-00606000 rw-p 00005000 08:0e 925727 jBox.x
    00606000-00681000 rw-p 00606000 00:00 0 [heap]
    2b7378a48000-2b7378a62000 r-xp 00000000 08:06 138178 /lib64/ld-2.7.so
    2b7378a62000-2b7378a64000 rw-p 2b7378a62000 00:00 0
    2b7378c61000-2b7378c62000 r--p 00019000 08:06 138178 /lib64/ld-2.7.so
    2b7378c62000-2b7378c63000 rw-p 0001a000 08:06 138178 /lib64/ld-2.7.so
    2b7378c63000-2b7379547000 r-xp 00000000 08:09 1245629 /usr/lib64/qt-4.4.1/lib/libQtGui.so.4.4.1
    2b7379547000-2b7379747000 ---p 008e4000 08:09 1245629 /usr/lib64/qt-4.4.1/lib/libQtGui.so.4.4.1
    2b7379747000-2b737978c000 rw-p 008e4000 08:09 1245629 /usr/lib64/qt-4.4.1/lib/libQtGui.so.4.4.1
    2b737978c000-2b737978e000 rw-p 2b737978c000 00:00 0
    2b737978e000-2b737978f000 r--p 00000000 08:09 1647920 /usr/share/locale/sl_SI.UTF-8/LC_IDENTIFICATION
    2b737978f000-2b7379796000 r--s 00000000 08:09 1147127 /usr/lib64/gconv/gconv-modules.cache
    2b7379796000-2b7379797000 r--p 00000000 08:09 1425414 /usr/share/locale/sl_SI.UTF-8/LC_MEASUREMENT
    2b7379797000-2b7379798000 r--p 00000000 08:09 1647923 /usr/share/locale/sl_SI.UTF-8/LC_TELEPHONE
    2b7379798000-2b7379799000 r--p 00000000 08:09 1647915 /usr/share/locale/sl_SI.UTF-8/LC_ADDRESS
    2b7379799000-2b737979a000 r--p 00000000 08:09 1425412 /usr/share/locale/sl_SI.UTF-8/LC_NAME
    2b737979a000-2b737979b000 r--p 00000000 08:09 1647927 /usr/share/locale/sl_SI.UTF-8/LC_PAPER
    2b737979b000-2b737979c000 r--p 00000000 08:09 1648302 /usr/share/locale/en_US.UTF-8/LC_MESSAGES/SYS_LC_MESSAGES
    2b737979c000-2b737979d000 r--p 00000000 08:09 1425413 /usr/share/locale/sl_SI.UTF-8/LC_MONETARY
    2b73797ad000-2b73797d3000 r-xp 00000000 08:09 1148977 /usr/lib64/libpng12.so.0.25.0
    2b73797d3000-2b73799d3000 ---p 00026000 08:09 1148977 /usr/lib64/libpng12.so.0.25.0
    2b73799d3000-2b73799d4000 rw-p 00026000 08:09 1148977 /usr/lib64/libpng12.so.0.25.0
    2b73799d4000-2b73799dc000 r-xp 00000000 08:09 1148972 /usr/lib64/libSM.so.6.0.0
    2b73799dc000-2b7379bdb000 ---p 00008000 08:09 1148972 /usr/lib64/libSM.so.6.0.0
    2b7379bdb000-2b7379bdc000 rw-p 00007000 08:09 1148972 /usr/lib64/libSM.so.6.0.0
    2b7379bdc000-2b7379bdd000 rw-p 2b7379bdc000 00:00 0
    2b7379bdd000-2b7379bf3000 r-xp 00000000 08:09 1148916 /usr/lib64/libICE.so.6.3.0
    2b7379bf3000-2b7379df3000 ---p 00016000 08:09 1148916 /usr/lib64/libICE.so.6.3.0
    2b7379df3000-2b7379df4000 rw-p 00016000 08:09 1148916 /usr/lib64/libICE.sAborted
    and i'm clueless.

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 162 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: *** glibc detected ***: free(): invalid pointer

    Lesson of the day: Do not lie to your compiler!

    Your class is not a QDialog, so do not cast it to pretend it is.
    Inherit your class from QDialog instead of QWidget, drop that cast, and it should work.

    (If you create a QMainWindow in designer, inherit from QMainWindow.)

    HTH

  3. #3
    Join Date
    Apr 2007
    Posts
    76
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: *** glibc detected ***: free(): invalid pointer

    i don't understand...
    based on this lesson QtDesigner

    i can not see the difference.

  4. #4
    Join Date
    Jul 2008
    Location
    Netherlands
    Posts
    33
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: *** glibc detected ***: free(): invalid pointer

    Quote Originally Posted by codebehind View Post
    Qt Code:
    1. myClass::myClass(QWidget *parent): QWidget(parent)
    2. {
    3. qDebug()<<"Initializing Form";
    4. setupUi((QDialog *)this);
    5. }
    6.  
    7. myClass::~myClass(){}
    To copy to clipboard, switch view to plain text mode 
    caduel is referring to line 4 of this piece of code. You're casting the pointer "this" to a pointer of type QDialog, which is not allowed. The example you're referring to uses setupUi(this), so I don't understand why you're casting the pointer?

    If you made a dialog in QtDesigner (and not a widget), your class should inheret from QDialog, as cadual already mentioned:

    Qt Code:
    1. class myClass : public QDialog, private Ui::myForm
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Apr 2007
    Posts
    76
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: *** glibc detected ***: free(): invalid pointer

    my bad...

    i haven't look at calculatorform.ui code. it is defined as QWidget and not QDialog.

    Thanks for your time and explanations - both of you.

    I've done another test app the same way (haven't declared it as QWidget and typecast it in the constructor) and it works just fine... so I repeat the mistake. the difference is that this time the app crashed.

Similar Threads

  1. itemChange() glibc invalid pointer
    By dreamer in forum Qt Programming
    Replies: 2
    Last Post: 3rd May 2008, 10:04
  2. Client/Server Error: BadIDChoice
    By 3nc31 in forum Qt Programming
    Replies: 5
    Last Post: 27th November 2007, 11:22

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.