Assert logic reversed in chSemResetWithMessageI(...) Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
User avatar
FXCoder
Posts: 264
Joined: Sun Jun 12, 2016 4:10 am
Location: Sydney, Australia
Has thanked: 106 times
Been thanked: 83 times

Assert logic reversed in chSemResetWithMessageI(...)  Topic is solved

Postby FXCoder » Sat Aug 01, 2020 1:22 pm

Hi.
The assert check for inconsistent semaphore in chSemResetWithMessageI(...) is reversed.
Assert condition should be cnt >= 0 and queue not empty OR cnt < 0 and queue is empty.
--
Bob

Code: Select all

Index: chsem.c
===================================================================
--- chsem.c   (revision 13802)
+++ chsem.c   (working copy)
@@ -144,8 +144,8 @@
 
   chDbgCheckClassI();
   chDbgCheck((sp != NULL) && (n >= (cnt_t)0));
-  chDbgAssert(((sp->cnt >= (cnt_t)0) && queue_isempty(&sp->queue)) ||
-              ((sp->cnt < (cnt_t)0) && queue_notempty(&sp->queue)),
+  chDbgAssert(((sp->cnt >= (cnt_t)0) && queue_notempty(&sp->queue)) ||
+              ((sp->cnt < (cnt_t)0) && queue_isempty(&sp->queue)),
               "inconsistent semaphore");
 
   sp->cnt = n;
Last edited by FXCoder on Sat Aug 01, 2020 1:59 pm, edited 1 time in total.

User avatar
Giovanni
Site Admin
Posts: 12943
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 729 times
Been thanked: 609 times
Contact:

Re: Assert logic reversed in chSemResetWithMessageI(...)

Postby Giovanni » Sat Aug 01, 2020 1:28 pm

Heh, just after the release...

I will make a 20.3.3 right now.

Giovanni

User avatar
Giovanni
Site Admin
Posts: 12943
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 729 times
Been thanked: 609 times
Contact:

Re: Assert logic reversed in chSemResetWithMessageI(...)

Postby Giovanni » Sat Aug 01, 2020 2:27 pm

After checking, I think the logic is right, when the counter is non-negative then the list must be empty.

Giovanni

User avatar
FXCoder
Posts: 264
Joined: Sun Jun 12, 2016 4:10 am
Location: Sydney, Australia
Has thanked: 106 times
Been thanked: 83 times

Re: Assert logic reversed in chSemResetWithMessageI(...)

Postby FXCoder » Sat Aug 01, 2020 4:31 pm

Agreed.
Put it down to late night madness coming from chasing a strange semaphore condition with the guarded pool in factory FIFO.

I'll send a PM about that.
--
Bob


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 6 guests