Uploaded image for project: 'Qt for MCUs'
  1. Qt for MCUs
  2. QTMCU-183

pushBack operation in circularbuffer is not atomic causing QulError_CircularBuffer_PopEmpty to be triggered.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • Qt for MCUs 2.5, Qt for MCUs 2.2
    • Platform Team, QUL Team
    • None
    • freeRTOS

    Description

      When qul is running in a low priority task and writes to the queue using a higher priority task, then it will destroy the queue count, triggering QulError_CircularBuffer_PopEmpty which will cause the display screen to get stuck.
       
      The exact point of failure should be here in file include\platform\private\circularbuffer.h:89
      void popFront(void *event)
      {
          QUL_DEBUG_ASSERT(m_begin != -1 && m_last != -1, QulError_CircularBuffer_PopEmpty);
          memcpy(event, m_data + m_begin * m_itemSize, m_itemSize);
          if (m_begin == m_last) {
              m_begin = -1;
              // a higher priority task calls pushBack(const void *event) here
              m_last = -1;
          } else

      {         m_begin = next(m_begin);     }

      }
      The probability of this problem is very low, but if using FreeRTOS, adding a 100ms delay to the red section can simply reproduce the problem.
       
      A temporary fix is to put a mutex lock on this part of the code to make it atomic, but this is potentially risky (e.g., causing a priority inversion)

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            macsen Macsen WANG
            Yoann Lopes Yoann Lopes
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes