[m-rev.] diff: Fix bug #233

Paul Bone pbone at csse.unimelb.edu.au
Thu Nov 24 23:22:58 AEDT 2011


Fix an error where the runtime system aborted with "sem_post: Invalid
argument".

runtime/mercury_context.c:
    The error message as important, since sem_timedwait actually raised the
    error.  When this occurred the error was incorrectly reported as being
    raised by the sem_post syscall.

    Use >= rather than > when testing if the nanoseconds field of a timeval
    structure for sem_timedwait should overflow into the seconds field.

Index: runtime/mercury_context.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_context.c,v
retrieving revision 1.103
diff -u -p -b -r1.103 mercury_context.c
--- runtime/mercury_context.c	27 Oct 2011 05:03:50 -0000	1.103
+++ runtime/mercury_context.c	24 Nov 2011 12:17:48 -0000
@@ -1857,7 +1857,7 @@ MR_define_entry(MR_do_sleep);
         /* Sleep for 2ms */
         tv.tv_usec += 2000;
 
-        if (tv.tv_usec > 1000000) {
+        if (tv.tv_usec >= 1000000) {
             tv.tv_usec = tv.tv_sec % 1000000;
             tv.tv_sec += 1;
         }
@@ -1949,7 +1949,7 @@ MR_define_entry(MR_do_sleep);
                     MR_MAYBE_TRAMPOLINE(do_work_steal(NULL));
                     break;
                 default:
-                    perror("sem_post");
+                    perror("sem_timedwait");
                     abort();
             }
         }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 489 bytes
Desc: Digital signature
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20111124/bd1e8234/attachment.sig>


More information about the reviews mailing list