[cxx-mem-model] gdb testing changes to avoid infinite loops.

Andrew MacLeod amacleod@redhat.com
Tue Oct 4 19:01:00 GMT 2011


THe framework for invoking gdb and simulating other threads can run into 
a problem when memmodel_other_thread() is written in a hostile manner.

memodel_other_thread ()
{
   mem++;     /* increment mem every instruction.  */
}

and it is tested against something like a compare_and_swap loop 
implementing add.

r1 = mem
loop:
r2 = r2 + value;
if (r1 = Compare_and_Swap (&mem, r1, r2))
    goto loop;

the value of mem will always change between loading it into r1 and the 
execution of the compare and swap after the add.  This causes the 
testcase to go into an infinite loop trying to make forward progress.

This adds a hostile thread check to the framework such that if more 
instructions are executed by the test than a specified threshold, a 
pause is inserted in calling memmodel_other_thread allowing forward 
progress to be made.

A testcase can opt to make this an error condition, but defaults to not 
an error.  It could be used to test for forward progress down the road 
perhaps.

Andrew
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: hostile.diff
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20111004/9257e519/attachment.ksh>


More information about the Gcc-patches mailing list