RTEMS | previous is not always NULL for node set off chain (#5491)

Chandan U (@Chandanuvm) gitlab at rtems.org
Tue Feb 24 16:54:10 UTC 2026




Chandan U commented: https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5491#note_143417


## 2nd BUG:-

I compiled the testsuites for the configuration, **SMP=true** and **DEBUG=TRUE/FALSE**,

**Before:**

![Screenshot from 2026-02-23 23-13-47.png](/uploads/d6a4e1f7c0bbb8798e14b4cd95763d96/Screenshot_from_2026-02-23_23-13-47.png){width="225" height="141"}

First file which generated the bug,

![Screenshot from 2026-02-24 00-27-12.png](/uploads/5cd61e6197f077bb1d746eb983537c43/Screenshot_from_2026-02-24_00-27-12.png){width="900" height="331"}

GDB debug back tracing from the break point,

![Screenshot from 2026-02-24 00-29-10.png](/uploads/2b4006dc4a80555c606e269d57086692/Screenshot_from_2026-02-24_00-29-10.png){width="900" height="222"}

function calls flow and relevant files checked,

![WhatsApp Image 2026-02-24 at 01.36.25.jpeg](/uploads/783c0b838a3687d2a4470b781627d87a/WhatsApp_Image_2026-02-24_at_01.36.25.jpeg){width="743" height="600"}

In smpmrsp01 , When semaphore is created , next == NULL and prev == garbage, and then it is trying to delete the semaphore created to test the deletion of semaphore.

So it calls `test_mrsp_flush_error()` which eventually calls `__Semaphore__Free()` Which asks the generic Object Manager to free this specific object which eventually calls` _Chain_Append_unprotected()`.

`_Chain_Append_unprotected()` contains `_Assert( _Chain_Is_node_off_chain( the_node ) )` in debug mode and since it asserts if prev != NULL which is true in this case, It throws an assertion error.

Solution proposed, Since generic Object manager cannot be changed and the assertion is only in debug mode, So in semimpl.h below changes can be done,

```
#if defined( RTEMS_DEBUG ) 
_Semaphore_Set_flags( the_semaphore, 0 ); 
#endif
```

Since while adding the chain to Free_chain queue the connections are made sure, only in debug mode it checks for the prev==NULL, So to optimize the cpu performance, the semaphore prev is made null only in debug mode.

**After:**

![Screenshot from 2026-02-24 01-29-18 \(1\).png](/uploads/f33326431bafcd5e8a832938f945f05e/Screenshot_from_2026-02-24_01-29-18__1_.png){width="283" height="322"}

The new failure is from new bug, and will be fixed next.

Please guide me in this, Thank you.

I have updated the MR with the first bug fix, https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1067

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5491#note_143417
You're receiving this email because of your account on gitlab.rtems.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20260224/636aa3b2/attachment-0001.htm>


More information about the bugs mailing list