apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philip Martin <phi...@codematters.co.uk>
Subject Re: apr_proc_mutex is broken
Date Tue, 19 Nov 2002 00:58:42 GMT
Aaron Bannert <aaron@clove.org> writes:

> On Tue, Nov 19, 2002 at 12:34:17AM +0000, Philip Martin wrote:
> > Aaron Bannert <aaron@clove.org> writes:
> > 
> > > On Mon, Nov 18, 2002 at 09:25:08PM +0000, Philip Martin wrote:
> > > > Philip Martin <philip@codematters.co.uk> writes:
> > > > 
> > > > [snip patch]
> > > > 
> > > > > That should increase contention for the shared data, even a non-SMP
> > > > > machine might show the bug.  The original test sometimes passes on
my
> > > > > machine, with the above patch it always fails
> > > 
> > > What filesystem are you using?
> > 
> > ReiserFS, until now :)  Just tried ext2 and tmpfs and it fails there
> > as well.
> 
> Are you sure? I'm having a terrible time reproducing this. I 've been adding
> in error catching code all day and I'm seeing the problem you mentioned
> for when the shm file already exists, but if it doesn't exist I can't
> reproduce it.
> 
> I wouldn't at all be surprised if reiser has a problem with sysv shm on
> SMP boxes under that kernel. FWIW I've tried it on nfs and tmpfs... *shrug*
> 
> [we should probably bring this back to the dev@apr list, feel free to reply
> to this to the list :) ]

[dev@apr CC'd]

I'm using the following patch to the testsuite.  It increases the
amount of contention for the shared data, and causes the tests to fail
reliably on my SMP workstation, using ReiserFS, ext2 and tmpfs, as
well as on my non-SMP laptop using ext3.  Aaron is having problems
reproducing the bug, perhaps someone else could try.

Index: test/testglobalmutex.c
===================================================================
RCS file: /home/cvspublic/apr/test/testglobalmutex.c,v
retrieving revision 1.3
diff -u -r1.3 testglobalmutex.c
--- test/testglobalmutex.c	9 Apr 2002 06:45:06 -0000	1.3
+++ test/testglobalmutex.c	19 Nov 2002 00:48:46 -0000
@@ -65,7 +65,7 @@
 #include "test_apr.h"
 
 
-#define MAX_ITER 4000
+#define MAX_ITER 40
 #define MAX_COUNTER (MAX_ITER * 4)
 
 apr_global_mutex_t *global_lock;
@@ -82,13 +82,16 @@
 
     if (apr_proc_fork(*proc, p) == APR_INCHILD) {
         while (1) {
+            int x_t;
             apr_global_mutex_lock(global_lock); 
             if (i == MAX_ITER) {
                 apr_global_mutex_unlock(global_lock); 
                 exit(1);
             }
             i++;
-            (*x)++;
+            x_t = *x;
+            apr_sleep(1);
+            *x = x_t + 1;
             apr_global_mutex_unlock(global_lock); 
         }
         exit(1);
Index: test/testprocmutex.c
===================================================================
RCS file: /home/cvspublic/apr/test/testprocmutex.c,v
retrieving revision 1.10
diff -u -r1.10 testprocmutex.c
--- test/testprocmutex.c	9 Apr 2002 06:45:06 -0000	1.10
+++ test/testprocmutex.c	19 Nov 2002 00:48:46 -0000
@@ -65,7 +65,7 @@
 #include "test_apr.h"
 
 
-#define MAX_ITER 4000
+#define MAX_ITER 40
 #define MAX_COUNTER (MAX_ITER * 4)
 
 apr_proc_mutex_t *proc_lock;
@@ -82,13 +82,16 @@
 
     if (apr_proc_fork(*proc, p) == APR_INCHILD) {
         while (1) {
+            int x_t;
             apr_proc_mutex_lock(proc_lock); 
             if (i == MAX_ITER) {
                 apr_proc_mutex_unlock(proc_lock); 
                 exit(1);
             }
             i++;
-            (*x)++;
+            x_t = *x;
+            apr_sleep(1);
+            *x = x_t + 1;
             apr_proc_mutex_unlock(proc_lock); 
         }
         exit(1);


Disabling the pool cleanup with this patch causes the tests to pass.
This is obviously not a solution to the problem, it's simply a
demonstration of the cause of the problem.

Index: locks/unix/proc_mutex.c
===================================================================
RCS file: /home/cvspublic/apr/locks/unix/proc_mutex.c,v
retrieving revision 1.20
diff -u -r1.20 proc_mutex.c
--- locks/unix/proc_mutex.c	18 Nov 2002 01:59:03 -0000	1.20
+++ locks/unix/proc_mutex.c	19 Nov 2002 00:54:44 -0000
@@ -205,10 +205,12 @@
     apr_proc_mutex_t *mutex=mutex_;
     union semun ick;
     
+#if 0
     if (mutex->interproc->filedes != -1) {
         ick.val = 0;
         semctl(mutex->interproc->filedes, 0, IPC_RMID, ick);
     }
+#endif
     return APR_SUCCESS;
 }    
 

-- 
Philip Martin

Mime
View raw message