From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19502 invoked by alias); 30 Aug 2012 19:14:14 -0000 Received: (qmail 19486 invoked by uid 22791); 30 Aug 2012 19:14:13 -0000 X-SWARE-Spam-Status: No, hits=-3.1 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO sourceware.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 30 Aug 2012 19:14:00 +0000 From: "jsm28 at gcc dot gnu.org" To: glibc-bugs@sources.redhat.com Subject: [Bug nptl/14532] New: Generic sem_post race Date: Thu, 30 Aug 2012 19:14:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: nptl X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jsm28 at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org X-SW-Source: 2012-08/txt/msg00209.txt.bz2 http://sourceware.org/bugzilla/show_bug.cgi?id=14532 Bug #: 14532 Summary: Generic sem_post race Product: glibc Version: 2.16 Status: NEW Severity: normal Priority: P2 Component: nptl AssignedTo: unassigned@sourceware.org ReportedBy: jsm28@gcc.gnu.org CC: drepper.fsp@gmail.com Classification: Unclassified The generic Linux version of sem_post (nptl/sysdeps/unix/sysv/linux/sem_post.c) uses atomic_compare_and_exchange_bool_acq to increment the semaphore. This is an unlock operation and should actually be using a release barrier. The following test fails on some MIPS systems (MIPS uses the generic version of sem_post where various architectures use their own .S versions). Testing a patch. #include #include #include #define NTHREADS 10 #define NITER 100000 sem_t sem; int c; volatile int thread_fail; static void * tf (void *arg) { for (int i = 0; i < NITER; i++) { if (sem_wait (&sem) != 0) { perror ("sem_wait"); thread_fail = 1; } ++c; if (sem_post (&sem) != 0) { perror ("sem_post"); thread_fail = 1; } } return NULL; } int main (void) { if (sem_init (&sem, 0, 0) != 0) { perror ("sem_init"); return 1; } pthread_t th[NTHREADS]; for (int i = 0; i < NTHREADS; i++) { if (pthread_create (&th[i], NULL, tf, NULL) != 0) { puts ("pthread_create failed"); return 1; } } if (sem_post (&sem) != 0) { perror ("sem_post"); return 1; } for (int i = 0; i < NTHREADS; i++) if (pthread_join (th[i], NULL) != 0) { puts ("pthread_join failed"); return 1; } if (c != NTHREADS * NITER) { printf ("c = %d, should be %d\n", c, NTHREADS * NITER); return 1; } return thread_fail; } -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.