PR# 14969 Postcondition violation: Synchronized

Problem Report Summary
Submitter: randyjohn
Category: Runtime
Priority: Medium
Date: 2008/11/06
Class: Bug
Severity: Non-critical
Number: 14969
Release: 6.3.7.4554
Confidential: No
Status: Open
Responsible:
Environment: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; WOW64; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; InfoPath.1; .NET CLR 3.0.04506.648)
Synopsis: Postcondition violation: Synchronized

Description
I failed a post-condition at the bottom of 'eif_synchronize_gc':

   ENSURE("Synchronized", eif_is_synchronized())

However, I believe that the error is spurious.  Here is how it happened.  I have only two Eiffel threads, A and B.  Thread A is in {STREAM_SOCKET}.c_accept:

   EIF_ENTER_C;     // gc_thread_status = EIF_THREAD_BLOCKED
   Result = (EIF_INTEGER_32) c_accept(arg1, arg2, arg3);
   EIF_EXIT_C;      // gc_thread_status = EIF_THREAD_RUNNING
   RTGC;            // gc_thread_status = EIF_THREAD_SUSPENDED

Let us assume that thread A is in the call to 'c_accept' right now and it's status is BLOCKED.  Thread B calls 'collect' and goes to 'eif_synchronize_gc'.  It goes into a loop to wait for all threads to be not RUNNING.  This happens right away because thread A is BLOCKED.  It is about to call the post condition.  But first, we go back to thread A.  It returns from 'c_accept' and calls EIF_EXIT_C which sets the status to RUNNING.  Now, back to thread B which calls the post condition and discovers (horror) that thread A is RUNNING!

But actually, everything is fine.  Thread A is about to call RTGC which will synch with the GC mutex.  The problem is that thread A briefly enters the RUNNING state after returning from 'c_accept'.  What is need is to combine EIF_EXIT_C with RTGC so that it goes straight to SUSPENDED.  Or perhaps call RTGC before calling EIF_EXIT_C.

Randy

p.s.  You will notice that I used "post condition" without the hyphen.  That is because the message gets corrupted (as seen in Preview) when I do.  It will be intesting to see what this looks like when I get it back.  Here is my original message with all hyphens restored (the first didn't cause any problems).  Look at the left border of the last two paragraphs and the missing last letter of the preceding line.

=================================================

I failed a post-condition at the bottom of 'eif_synchronize_gc':

   ENSURE("Synchronized", eif_is_synchronized())

However, I believe that the error is spurious.  Here is how it happened.  I have only two Eiffel threads, A and B.  Thread A is in {STREAM_SOCKET}.c_accept:

   EIF_ENTER_C;     // gc_thread_status = EIF_THREAD_BLOCKED
   Result = (EIF_INTEGER_32) c_accept(arg1, arg2, arg3);
   EIF_EXIT_C;      // gc_thread_status = EIF_THREAD_RUNNING
   RTGC;            // gc_thread_status = EIF_THREAD_SUSPENDED

Let us assume that thread A is in the call to 'c_accept' right now and it's status is BLOCKED.  Thread B calls 'collect' and goes to 'eif_synchronize_gc'.  It goes into a loop to wait for all threads to be not RUNNING.  This happens right away because thread A is BLOCKED.  It is about to call the post-condition.  But first, we go back to thread A.  It returns from 'c_accept' and calls EIF_EXIT_C which sets the status to RUNNING.  Now, back to thread B which calls the post-condition and discovers (horror) that thread A is RUNNING!

But actually, everything is fine.  Thread A is about to call RTGC which will synch with the GC mutex.  The problem is that thread A briefly enters the RUNNING state after returning from 'c_accept'.  What is need is to combine EIF_EXIT_C with RTGC so that it goes straight to SUSPENDED.  Or perhaps call RTGC before calling EIF_EXIT_C.

Randy
To Reproduce

										
Problem Report Interactions