Menu

#271 Assert 250 upon semaphone wait timeout

QPCPP
closed
None
1
2024-08-01
2020-06-15
Anonymous
No

In qxk_sema.cpp, line 153,

// did the blocking time-out? (signal of zero means that it did)
if (curr->m_timeEvt.sig != static_cast<qsignal>(0)) {</qsignal>

The code does NOT agree with the comment. Checking how the m_timeEvt.sig is used in QP, it looks like the comment is correct. For example, there is a similar code in qxk_mutex.cpp and it looks like it's correct there.

This issue was found when running 6.5.1. The source code of the latest 6.8.1 indicates that it is still an issue.

Discussion

  • Quantum Leaps

    Quantum Leaps - 2020-06-15

    Thank you for reporting. The bug is the reversed condition tested in qxk_sema.cpp:153. Here is the patch to fix this:

    @@ -153,5 +153,5 @@ bool QXSemaphore::wait(std::uint_fast16_t const nTicks) noexcept {
    
             // did the blocking time-out? (signal of zero means that it did)
    
    -        if (curr->m_timeEvt.sig != 0U) {
    +        if (curr->m_timeEvt.sig == 0U) {
                 if (m_waitSet.hasElement(p)) { // still waiting?
                     m_waitSet.rmove(p); // remove the unblocked thread
    

    The bug has been fixed in the QP/C++ git repositories (on GitHub and SourceForge). The QP-bundle will be fixed in the next release.

    NOTE: this bug is NOT present in QP/C, where the corresponding code is correct.

    --MMS

     

    Last edit: Quantum Leaps 2020-06-15
  • Quantum Leaps

    Quantum Leaps - 2020-07-19

    Fixed in QP/C++ 6.8.2.
    --MMS

     

Anonymous
Anonymous

Add attachments
Cancel