From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24729 invoked by alias); 13 Mar 2013 19:24:42 -0000 Received: (qmail 24719 invoked by uid 22791); 13 Mar 2013 19:24:39 -0000 X-SWARE-Spam-Status: No, hits=-7.0 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_GC X-Spam-Check-By: sourceware.org Received: from mx3-phx2.redhat.com (HELO mx3-phx2.redhat.com) (209.132.183.24) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 13 Mar 2013 19:24:21 +0000 Received: from zmail17.collab.prod.int.phx2.redhat.com (zmail17.collab.prod.int.phx2.redhat.com [10.5.83.19]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r2DJOKQB012354 for ; Wed, 13 Mar 2013 15:24:20 -0400 Date: Wed, 13 Mar 2013 19:24:00 -0000 From: Andrew Hughes To: GCJ-patches Message-ID: <1186349091.18187087.1363202660791.JavaMail.root@redhat.com> In-Reply-To: <287047809.18185663.1363202448566.JavaMail.root@redhat.com> Subject: [PATCH] Use pthread_equal to compare thread IDs MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_18187085_965658483.1363202660789" X-IsSubscribed: yes Mailing-List: contact java-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-patches-owner@gcc.gnu.org X-SW-Source: 2013-q1/txt/msg00022.txt.bz2 ------=_Part_18187085_965658483.1363202660789 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 1630 We've recently seen some sporadic IllegalMonitorStateException failures from gcj on amd64, ppc32 & ppc64 when building IcedTea against the latest glibc. Due to the nature of the failure, it's hard to confirm that the attached patch will fix the issue, but it seems correct to remedy this either way. When determining if the mutex is held by the current thread in notifyAll, gcj's POSIX threads implementation compares the result of pthread_self and the owner of the mutex using !=. However, pthread_self's man page states: "POSIX.1 allows an implementation wide freedom in choosing the type used to represent a thread ID; for example, representation using either an arithmetic type or a structure is permitted. Therefore, variables of type pthread_t can't portably be compared using the C equality operator (==); use pthread_equal(3) instead. Thread identifiers should be considered opaque: any attempt to use a thread ID other than in pthreads calls is nonportable and can lead to unspecified results." While the use of != has worked in the past, I suspect a change in glibc may have broken this. Either way, it seems sensible to fix this and use pthread_equal to compare the identifiers as in the attached patch. ChangeLog: 2013-03-12 Andrew John Hughes * include/posix-threads.h: (_Jv_MutexCheckMonitor(_Jv_Mutex_t)): Use pthread_equal rather than !=. Ok for trunk? -- Andrew :) Free Java Software Engineer Red Hat, Inc. (http://www.redhat.com) PGP Key: 248BDC07 (https://keys.indymedia.org/) Fingerprint = EC5A 1F5E C0AD 1D15 8F1F 8F91 3B96 A578 248B DC07 ------=_Part_18187085_965658483.1363202660789 Content-Type: text/x-patch; name=pthread_equal.patch Content-Disposition: attachment; filename=pthread_equal.patch Content-Transfer-Encoding: base64 Content-length: 582 SW5kZXg6IGxpYmphdmEvaW5jbHVkZS9wb3NpeC10aHJlYWRzLmgKPT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PQotLS0gbGliamF2YS9pbmNsdWRlL3Bvc2l4LXRo cmVhZHMuaAkocmV2aXNpb24gMTk2NjAxKQorKysgbGliamF2YS9pbmNsdWRl L3Bvc2l4LXRocmVhZHMuaAkod29ya2luZyBjb3B5KQpAQCAtNzksNyArNzks NyBAQAogaW5saW5lIGludAogX0p2X011dGV4Q2hlY2tNb25pdG9yIChfSnZf TXV0ZXhfdCAqbXUpCiB7Ci0gIHJldHVybiAobXUtPm93bmVyICE9IHB0aHJl YWRfc2VsZigpKTsKKyAgcmV0dXJuIChwdGhyZWFkX2VxdWFsKG11LT5vd25l ciwgcHRocmVhZF9zZWxmKCkpID09IDApOwogfQogCiAvLyBUeXBlIGlkZW50 aWZ5aW5nIGEgUE9TSVggdGhyZWFkLgo= ------=_Part_18187085_965658483.1363202660789--