From owner-freebsd-threads@FreeBSD.ORG Mon Jul 6 09:40:04 2009 Return-Path: Delivered-To: freebsd-threads@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 874F7106567A for ; Mon, 6 Jul 2009 09:40:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 5A5838FC1B for ; Mon, 6 Jul 2009 09:40:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n669e4nS036524 for ; Mon, 6 Jul 2009 09:40:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n669e463036523; Mon, 6 Jul 2009 09:40:04 GMT (envelope-from gnats) Date: Mon, 6 Jul 2009 09:40:04 GMT Message-Id: <200907060940.n669e463036523@freefall.freebsd.org> To: freebsd-threads@FreeBSD.org From: dfilter@FreeBSD.ORG (dfilter service) Cc: Subject: Re: threads/136345: commit references a PR X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: dfilter service List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jul 2009 09:40:05 -0000 The following reply was made to PR threads/136345; it has been noted by GNATS. From: dfilter@FreeBSD.ORG (dfilter service) To: bug-followup@FreeBSD.org Cc: Subject: Re: threads/136345: commit references a PR Date: Mon, 6 Jul 2009 09:31:15 +0000 (UTC) Author: attilio Date: Mon Jul 6 09:31:04 2009 New Revision: 195403 URL: http://svn.freebsd.org/changeset/base/195403 Log: In the current code, rdlock_count is not correctly handled for some cases. The most notable is that it is not bumped in rwlock_rdlock_common() when the hard path (__thr_rwlock_rdlock()) returns successfully. This can lead to deadlocks in libthr when rwlocks recursion in read mode happens. Fix the interested parts by correctly handling rdlock_count. PR: threads/136345 Reported by: rink Tested by: rink Reviewed by: jeff Approved by: re (kib) MFC: 2 weeks Modified: head/lib/libthr/thread/thr_rtld.c head/lib/libthr/thread/thr_rwlock.c Modified: head/lib/libthr/thread/thr_rtld.c ============================================================================== --- head/lib/libthr/thread/thr_rtld.c Mon Jul 6 09:07:35 2009 (r195402) +++ head/lib/libthr/thread/thr_rtld.c Mon Jul 6 09:31:04 2009 (r195403) @@ -114,6 +114,7 @@ _thr_rtld_rlock_acquire(void *lock) THR_CRITICAL_ENTER(curthread); while (_thr_rwlock_rdlock(&l->lock, 0, NULL) != 0) ; + curthread->rdlock_count++; RESTORE_ERRNO(); } @@ -148,6 +149,7 @@ _thr_rtld_lock_release(void *lock) state = l->lock.rw_state; if (_thr_rwlock_unlock(&l->lock) == 0) { + curthread->rdlock_count--; if ((state & URWLOCK_WRITE_OWNER) == 0) { THR_CRITICAL_LEAVE(curthread); } else { Modified: head/lib/libthr/thread/thr_rwlock.c ============================================================================== --- head/lib/libthr/thread/thr_rwlock.c Mon Jul 6 09:07:35 2009 (r195402) +++ head/lib/libthr/thread/thr_rwlock.c Mon Jul 6 09:31:04 2009 (r195403) @@ -177,10 +177,11 @@ rwlock_rdlock_common(pthread_rwlock_t *r /* if interrupted, try to lock it in userland again. */ if (_thr_rwlock_tryrdlock(&prwlock->lock, flags) == 0) { ret = 0; - curthread->rdlock_count++; break; } } + if (ret == 0) + curthread->rdlock_count++; return (ret); } _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"