Results 1 to 4 of 4

Thread: segmentation fault

  1. #1
    Join Date
    Oct 2009
    Posts
    90
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default segmentation fault

    Hello

    I some times in debugging run (F5) receive segmentation fault. But in normal run (Ctrl+R) , it seems every thing is good.

    and it is a trace :
    level - function - file - line - address
    0 - QMutex::lock - qmutex.cpp - 150 - 0x6a110bae
    1 - QMutexLocker::relock - qmutex.h - 120 - 0x0043da4a
    2 - QMutexLocker - qmutex.h - 102 - 0x0043daea
    3 - QextSerialPort::flush - win_qextserialport.cpp - 134 - 0x00433929

    where is error ?


    regards
    navid

  2. #2
    Join Date
    Sep 2009
    Location
    Tashkent, Uzbekistan
    Posts
    107
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: segmentation fault

    Show the code sample please. And use CODE quotes It is unclear what cause that error exactly.

  3. #3
    Join Date
    Oct 2009
    Posts
    90
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: segmentation fault

    Qt Code:
    1. void QextSerialPort::flush() {
    2. QMutexLocker lock(mutex); // line 134
    3. if (isOpen()) {
    4. FlushFileBuffers(Win_Handle);
    5. }
    6. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. inline explicit QMutexLocker(QMutex *m)
    2. : mtx(m)
    3. {
    4. Q_ASSERT_X((val & quintptr(1u)) == quintptr(0),
    5. "QMutexLocker", "QMutex pointer is misaligned");
    6. relock(); // line 102
    7. }
    8. inline ~QMutexLocker() { unlock(); }
    9.  
    10. inline void unlock()
    11. {
    12. if (mtx) {
    13. if ((val & quintptr(1u)) == quintptr(1u)) {
    14. val &= ~quintptr(1u);
    15. mtx->unlock();
    16. }
    17. }
    18. }
    19.  
    20. inline void relock()
    21. {
    22. if (mtx) {
    23. if ((val & quintptr(1u)) == quintptr(0u)) {
    24. mtx->lock(); //line 120
    25. val |= quintptr(1u);
    26. }
    27. }
    28. }
    To copy to clipboard, switch view to plain text mode 


    Qt Code:
    1. void QMutex::lock()
    2. {
    3. Qt::HANDLE self;
    4.  
    5. if (d->recursive) { //line 150 ... QMutex::QMutex(RecursionMode mode)
    6. //: d(new MutexPrivate(mode))
    7. self = QThread::currentThreadId();
    8. if (d->owner == self) {
    9. ++d->count;
    10. Q_ASSERT_X(d->count != 0, "QMutex::lock", "Overflow in recursion counter");
    11. return;
    12. }
    13.  
    14. bool isLocked = d->contenders.fetchAndAddAcquire(1) == 0;
    15. if (!isLocked) {
    16. #ifndef QT_NO_DEBUG
    17. if (d->owner == self)
    18. qWarning("QMutex::lock: Deadlock detected in thread %ld",
    19. long(d->owner));
    20. #endif
    21.  
    22. isLocked = d->wait();
    23. Q_ASSERT_X(isLocked, "QMutex::lock",
    24. "Internal error, infinite wait has timed out.");
    25.  
    26. d->contenders.deref();
    27. }
    28.  
    29. d->owner = self;
    30. ++d->count;
    31. Q_ASSERT_X(d->count != 0, "QMutex::lock", "Overflow in recursion counter");
    32. return;
    33. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Sep 2009
    Location
    Tashkent, Uzbekistan
    Posts
    107
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: segmentation fault

    Ok. It looks like debug dies on call FlushFileBuffers. If it is privileged call and you try to debug it without privileges - then you should get something like protection error.

    Regards,
    -- tanuki

Similar Threads

  1. Replies: 21
    Last Post: 28th September 2010, 11:59
  2. Replies: 2
    Last Post: 17th June 2010, 00:58
  3. Segmentation Fault when Program Starts
    By KaptainKarl in forum Newbie
    Replies: 7
    Last Post: 10th September 2009, 09:43
  4. Segmentation fault running any QT4 executables
    By jellis in forum Installation and Deployment
    Replies: 7
    Last Post: 19th May 2007, 17:35
  5. Icons missing => segmentation fault
    By antonio.r.tome in forum Qt Programming
    Replies: 4
    Last Post: 8th March 2006, 17:30

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.