Issue-5491: previous is not always NULL for node set off chain

hello @gedare @JoelSherrill ,
i’m working on this issue, 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:

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

from this i ran the file using GDB to debug it, and got the function calls through back tracing which led to the assertion,

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

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:

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,

This kind of discussion rightly belongs on the Issue itself or the MR.

Okay, I will create a comment in the issue.
Thank you.