RTEMS | previous is not always NULL for node set off chain (#5491)
Chandan U (@Chandanuvm)
gitlab at rtems.org
Mon Feb 23 19:14:17 UTC 2026
Chandan U commented: https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5491#note_143340
hello @gedare @joel from all the guidance and suggestions i recieved, i carefully reproduced the bug. There are 3-4 bug fixation needed, i'm documenting each bug fix seperately.
## 1st BUG:-
I compiled the testsuites for the configuration, **SMP=true** and **DEBUG=TRUE/FALSE**,
**Before:**
{width=240 height=145}
I generated the logs and checked for the first file which generated the bug,
{width=621 height=600}
from this i ran the file using GDB to debug it, and got the function calls through back tracing which led to the assertion,
{width=670 height=259}
from this i looked into the relevant code files and understood the flow,
{width=900 height=486}
Clearly the smp01.c code tried to print something to the screen. To do this safely (so two CPUs don't write over each other), it tried to grab a Semaphore.
So it wanted a free semaphore , and it called Semaphore_Get_flags which checks if the chain is free by \_Chain_is_node_off_chain(), But semaphores store their flags in prev pointer, Since the \_Chain_is_node_off_chain() got stricter in debug mode i.e asserts if prev!=null it was throwing error.
But prev need not be cleared for a free chain, Since its prev eventually gets replaced with new flags , so only next==null check is enough.
Bug fix solution proposed, replace `_Assert( _Chain_Is_node_off_chain( &the_semaphore->Object.Node ) );` with `_Assert( the_semaphore->Object.Node.next == NULL );` in the `_Semaphore_Get_flags` function. Similarly for the `_Semaphore_Set_flags` function.
**After:**
{width=225 height=141}
The new failures are from new bug and are dealt seperately and will be documented seperately.
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_143340
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/20260223/f1a14143/attachment-0001.htm>
More information about the bugs
mailing list