Results 1 to 5 of 5

Thread: a segmentation fault

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2011
    Posts
    3
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default a segmentation fault

    I was beaten by a segmentation fault,
    following is my source code

    Qt Code:
    1. void PieceThread::slotReadReady()
    2. {
    3. while(reply!=NULL&&!pauseFlag&&!reply->atEnd())
    4. {
    5. QMutexLocker locker(&mutex);
    6. file->seek(workingPos);
    7. workingPos+=file->write(reply->read(4096)); //segmentation fault happend here!
    8. emit this->signalProgressIncrease(workingPos-oldWorkingPos);
    9. oldWorkingPos=workingPos;
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

    I promise that the "file" and the "reply" are legal pointer,

    following is the Call Stack Window

    0 QList<QNetworkReplyImplPrivate::InternalNotificati ons>::contains qlist.h 864 0x680cd407
    1 QNetworkReplyImplPrivate::backendNotify qnetworkreplyimpl.cpp 365 0x68048179
    2 QNetworkReplyImpl::readData qnetworkreplyimpl.cpp 873 0x6804a2f8
    3 QIODevice::read qiodevice.cpp 829 0x6a1ab817
    4 QIODevice::read qiodevice.cpp 964 0x6a1abd3b //here is the "read(4096)"
    5 PieceThread::slotReadReady piecethread.cpp 48 0x4048e3
    6 PieceThread::qt_metacall moc_piecethread.cpp 84 0x408a73
    7 QMetaObject::metacall qmetaobject.cpp 237 0x6a2060b0
    8 QMetaCallEvent:laceMetaCall qobject.cpp 535 0x6a210d55
    9 QObject::event qobject.cpp 1217 0x6a212c60
    10 QApplicationPrivate::notify_helper qapplication.cpp 4462 0x7ebde0
    11 QApplication::notify qapplication.cpp 3862 0x7e9732
    12 QCoreApplication::notifyInternal qcoreapplication.cpp 731 0x6a2015f8
    13 QCoreApplication::sendEvent qcoreapplication.h 215 0x6a268308
    14 QCoreApplicationPrivate::sendPostedEvents qcoreapplication.cpp 1372 0x6a2026a3
    15 qt_internal_proc qeventdispatcher_win.cpp 497 0x6a22499f
    16 USER32!GetDC C:\WINDOWS\system32\user32.dll 0 0x77d18734
    17 ?? 0 0x3301a4
    18 ?? 0 0x401
    19 ?? 0

    the line 0's call stack source code is from "qlist.h"

    Qt Code:
    1. Q_OUTOFLINE_TEMPLATE QBool QList<T>::contains(const T &t) const
    2. {
    3. Node *b = reinterpret_cast<Node *>(p.begin());
    4. Node *i = reinterpret_cast<Node *>(p.end());
    5. while (i-- != b)
    6. if (i->t() == t) //segmentation fault happend here
    7. return QBool(true);
    8. return QBool(false);
    9. }
    To copy to clipboard, switch view to plain text mode 




    thank you for helping me!
    Last edited by yaohao@qtcentre; 15th March 2011 at 13:49. Reason: missing [code] tags

Similar Threads

  1. QWT - Segmentation Fault
    By Wojtek.wk in forum Newbie
    Replies: 0
    Last Post: 17th April 2010, 15:29
  2. Segmentation Fault
    By jmc in forum Qt Tools
    Replies: 4
    Last Post: 24th February 2010, 21:08
  3. segmentation fault
    By dreamer in forum Qt Programming
    Replies: 6
    Last Post: 9th May 2008, 08:48
  4. Segmentation Fault?!
    By r07f1 in forum Newbie
    Replies: 2
    Last Post: 11th April 2008, 16:10
  5. Segmentation Fault
    By merry in forum General Programming
    Replies: 4
    Last Post: 12th March 2007, 05:08

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.