chMBPostTimeout: chSysHalt unsuspending timeouted reader thread

Discussions and support about ChibiOS/RT, the free embedded RTOS.
Post Reply
eee
Posts: 1
Joined: Fri Dec 20, 2019 9:30 am

chMBPostTimeout: chSysHalt unsuspending timeouted reader thread

Post by eee »

Using Chibios/RT 19.1.2.
One thread is doing

Code: Select all

chMBPostTimeout(&this->m_auxmsg_mbox, (msg_t)msg, TIME_IMMEDIATE);

(n.b: msg is a pointer to a message allocated from a memory pool)

Another thread is blocking on the mailbox:

Code: Select all

auto result = chMBFetchTimeout(&this->m_auxmsg_mbox, (msg_t *) &m, TIME_MS2I(10));


If the timeout occurs before the post, the post causes a chSysHalt via chThdDoDequeueNextI, specifically due to the line

Code: Select all

chDbgAssert(tp->state == CH_STATE_QUEUED, "invalid state");


However, if the timeout is [font=Courier New]TIME_IMMEDIATE[/font], the crash doesn't occur.

I should also note that even if the timeout is raised above the amount of time the posting thread takes, the message never comes through.

Am I somehow misusing message-boxes entirely? Any idea what's going on?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: chMBPostTimeout: chSysHalt unsuspending timeouted reader thread

Post by Giovanni »

Hi,

It is not very clear to me, could you check tp->state when the assertion occurs? please also get the stack trace at the assertion point.

Giovanni
Post Reply