Results 1 to 5 of 5

Thread: QDebug assert failure crash in QRingBuffer

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2020
    Posts
    7
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default QDebug assert failure crash in QRingBuffer

    Hi,
    I'm using a simple class called Scope that prints the current function name in cosructor and destructor for debugging purposes.
    So I get a message when the programs executes a function and when it leaves.

    This is the header

    Qt Code:
    1. #ifndef SCOPEDEBUG_H
    2. #define SCOPEDEBUG_H
    3.  
    4.  
    5. #define SHELL_RESET "\033[0m"
    6.  
    7. #define SHELL_RED "\033[031m"
    8. #define SHELL_GREEN "\033[032m"
    9. #define SHELL_YELLOW "\033[033m"
    10. #define SHELL_BLUE "\033[034m"
    11.  
    12.  
    13. #include <QDebug>
    14. #include <QString>
    15. #include <QElapsedTimer>
    16.  
    17. //#define NO_DEBUG_CALL_TRACE
    18.  
    19. #ifndef NO_DEBUG_CALL_TRACE
    20.  
    21. class Scope
    22. {
    23. public:
    24. Scope(const char *fn, const char *s="", const char* e="");
    25. ~Scope();
    26.  
    27. const char *func, *start, *end;
    28. };
    29.  
    30.  
    31. class ScopeTimer : Scope
    32. {
    33. public:
    34. ScopeTimer(const char *fn, const char *s="", const char* e="");
    35. ~ScopeTimer();
    36.  
    37. QElapsedTimer timer;
    38. };
    39.  
    40.  
    41.  
    42. # define DEBUG_ENTRY_NAME(name) Scope DBG(name)
    43. # define DEBUG_ENTRY DEBUG_ENTRY_NAME(__PRETTY_FUNCTION__)
    44. # define DEBUG_COLOR_ENTRY(color) Scope DBG(__PRETTY_FUNCTION__, color, SHELL_RESET)
    45. # define DEBUG_IMPORTANT_ENTRY DEBUG_COLOR_ENTRY(SHELL_GREEN)
    46.  
    47. # define DEBUG_TIME_ENTRY ScopeTimer DBG(__PRETTY_FUNCTION__)
    48.  
    49. #else
    50. # define DEBUG_ENTRY_NAME(name)
    51. # define DEBUG_ENTRY
    52. # define DEBUG_COLOR_ENTRY(color)
    53. # define DEBUG_IMPORTANT_ENTRY
    54. # define DEBUG_TIME_ENTRY
    55. #endif // NO_DEBUG_CALLTRACE
    56.  
    57. #endif // SCOPEDEBUG_H
    To copy to clipboard, switch view to plain text mode 

    And this is the cpp file:

    Qt Code:
    1. #include "app/scopedebug.h"
    2.  
    3. #ifndef NO_DEBUG_CALL_TRACE
    4.  
    5. static uint thread_local stackLevel = 0;
    6.  
    7. Scope::Scope(const char *fn, const char *s, const char *e) :
    8. func(fn),
    9. start(s),
    10. end(e)
    11. {
    12. qDebug().nospace().noquote()
    13. << start << QByteArray(" ").repeated(stackLevel) << ">>> " << func << end;
    14. stackLevel++;
    15. }
    16.  
    17. Scope::~Scope()
    18. {
    19. stackLevel--;
    20. qDebug().nospace().noquote()
    21. << start << QByteArray(" ").repeated(stackLevel) << "<<< " << func << end;
    22. }
    23.  
    24. ScopeTimer::ScopeTimer(const char *fn, const char *s, const char *e) :Scope(fn, s, e)
    25. {
    26. timer.start();
    27. }
    28.  
    29. ScopeTimer::~ScopeTimer()
    30. {
    31. qDebug() << "TOOK" << timer.elapsed() << "ms";
    32. }
    33.  
    34. #endif
    To copy to clipboard, switch view to plain text mode 

    The crash happens doesn't always happen and also it only happens if I start my program with debugger.
    Also if it's relevant I also start a QRunnable in the global threadpool and it also calls qDebug() at about the same time I think but the documentation says that qDebug() is thread-safe.
    Qt Version: 5.11.3 kit
    Compiler: MinGW 32 bit
    OS: Windows 8.1 64 bit

    This is the trace:

    Qt Code:
    1. 1 QMessageLogger::fatal qlogging.cpp 872 0x6b98fc96
    2. 2 qt_assert qglobal.cpp 3202 0x6b98a961
    3. 3 QRingBuffer::free qringbuffer.cpp 113 0x6b9e7295
    4. 4 QIODevicePrivate::QRingBufferRef::free qiodevice_p.h 100 0x6ba594f0
    5. 5 QFileDevice::flush qfiledevice.cpp 294 0x6ba594f0
    6. 6 QTextStreamPrivate::flushWriteBuffer qtextstream.cpp 609 0x6bb63e89
    7. 7 QTextStream::~QTextStream qtextstream.cpp 1163 0x6bb63f57
    8. 8 myMessageOutput main.cpp 48 0x406bbc
    9. 9 qt_message_print qlogging.cpp 1791 0x6b98f5dd
    10. 10 qt_message_output qlogging.cpp 1849 0x6b99041d
    11. 11 QDebug::~QDebug qdebug.cpp 156 0x6ba4d2bf
    12. 12 Scope::Scope scopedebug.cpp 12 0x40cf5a
    13. 13 JobPathEditor::clearJob jobpatheditor.cpp 293 0x41240f
    To copy to clipboard, switch view to plain text mode 

    QRingBuffer::free has an assert and I get always 70 bytes < 45 -> assert failure.
    Last edited by gfgit; 14th March 2020 at 14:58.

Similar Threads

  1. Replies: 3
    Last Post: 27th July 2011, 09:30
  2. Assert failure with tablet installed
    By Spectralist in forum Qt Programming
    Replies: 2
    Last Post: 21st April 2011, 13:31
  3. Problem debugging Assert failure.
    By Doug Broadwell in forum Qt Programming
    Replies: 3
    Last Post: 3rd January 2009, 18:39
  4. Debugging ASSERT failure in Qt header.
    By Doug Broadwell in forum Qt Programming
    Replies: 6
    Last Post: 27th December 2008, 01:40
  5. QWT assert failure
    By Andimat in forum Qwt
    Replies: 1
    Last Post: 21st June 2007, 14:36

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.