Libcanard Rx issue in stm32


I am evaluating libcanard on stm32f429 nucleo board. So far almost everything is working as expected, and I could successfully transmit (publish) messages on one board and receive them on another board (via subscribe). Also I am able to see transactions and network status informations using yakut on a raspberry pi.

The only issue I am facing so far is that after a while (ranging from 1h to 20h), the receiving node suddenly goes offline. After debugging the firmware to resolve the source of issue, I found out that the program asserts an illegal condition in unbin() function (o1heap.c, line 234). The function call history to this point is as follows:

exitQ at syscalls.c:62 0x8007542
abortO at Ox800abd6
assert funcO at 0x8009dd0
unbinO at olheap.c:234 0x8003d6a
olheapAllocate0 at o1heap.c:336 0x8004142
memAllocateQ at main.c:682 Ox8006f56
nxSessionWritePayloadQ at canard.c:692 0x8002cbc
IxSessionAcceptFrame0 at canard.c:766 0x8002f66
nSessionUpdate0 at canard.c:855 0x8003272
nxAcceptFrameO at canard.c:906 0x800344C
canardRxAcceptO at canard.c:1,110 0x:800386c
HAL_CAN _RxFifoOMsgPendingCallback0 at main.c:551 0x800634
HAL_CAN_IRQHandler0 at stm32f4xo_hal_can.c:1,910 08007e18
CAN1_RX0_IRQHandler0 at stm32f4xx_it.c.210 0x80074e2
<signal handler called> O at Oxffffff9
cavlFindExtremumO at cavl.h:83 0x:800159c
canardTxPeek0 at canard. c:1,055 0x8003752
mainO at main.c:251 0x8006752

I think this is due to can rx interrupt routine which occurs in the middle of some critical sections of stack processing routine. Is it safe to use interrupts in conjunction with libcanard?

Only if you protect the entire library with a critical section. The same holds for o1heap.

What you described sounds like an ordinary race condition defect.

Thank you,
The problem resolved as I used regular malloc() and free() functions instead of O1heap.