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:**

![Screenshot from 2026-02-23 
23-14-24.png](/uploads/5df373443d833feff55ec7a8ef0a0a03/Screenshot_from_2026-02-23_23-14-24.png){width=240
 height=145}

I generated the logs and checked for the first file which generated the bug,

![Screenshot from 2026-02-23 
22-37-46.png](/uploads/95b2ea5857408fc2bc25270051b30828/Screenshot_from_2026-02-23_22-37-46.png){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,

![Screenshot from 2026-02-23 
22-44-15.png](/uploads/899500dbbafecc87d600f7f84f58d941/Screenshot_from_2026-02-23_22-44-15.png){width=670
 height=259}

from this i looked into the relevant code files and understood the flow,

![WhatsApp Image 2026-02-23 at 
23.32.42.jpeg](/uploads/7e45bf4cbf29fc6f5729c3a520493eaa/WhatsApp_Image_2026-02-23_at_23.32.42.jpeg){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:**

![Screenshot from 2026-02-23 
23-13-47.png](/uploads/656a47425536fd1f758d4455b012d2b0/Screenshot_from_2026-02-23_23-13-47.png){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.


_______________________________________________
bugs mailing list
[email protected]
http://lists.rtems.org/mailman/listinfo/bugs

Reply via email to