From owner-svn-src-stable@FreeBSD.ORG Fri Nov 11 02:10:24 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6B802106564A; Fri, 11 Nov 2011 02:10:24 +0000 (UTC) (envelope-from rstone@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5AFA98FC0A; Fri, 11 Nov 2011 02:10:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pAB2AOQO066090; Fri, 11 Nov 2011 02:10:24 GMT (envelope-from rstone@svn.freebsd.org) Received: (from rstone@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pAB2AOod066088; Fri, 11 Nov 2011 02:10:24 GMT (envelope-from rstone@svn.freebsd.org) Message-Id: <201111110210.pAB2AOod066088@svn.freebsd.org> From: Ryan Stone Date: Fri, 11 Nov 2011 02:10:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227438 - stable/8/lib/libthr/thread X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Nov 2011 02:10:24 -0000 Author: rstone Date: Fri Nov 11 02:10:24 2011 New Revision: 227438 URL: http://svn.freebsd.org/changeset/base/227438 Log: MFC 220888 r179417 introduced a bug into pthread_once(). Previously pthread_once() used a global pthread_mutex_t for synchronization. r179417 replaced that with an implementation that directly used atomic instructions and thr_* syscalls to synchronize callers to pthread_once. However, calling pthread_mutex_lock on the global mutex implicitly ensured that _thr_check_init() had been called but with r179417 this was no longer guaranteed. This meant that if you were unlucky enough to have your first call into libthr be a call to pthread_once(), you would segfault when trying to access the pointer returned by _get_curthread(). The fix is to explicitly call _thr_check_init() from pthread_once(). Modified: stable/8/lib/libthr/thread/thr_once.c Directory Properties: stable/8/lib/libthr/ (props changed) Modified: stable/8/lib/libthr/thread/thr_once.c ============================================================================== --- stable/8/lib/libthr/thread/thr_once.c Fri Nov 11 02:02:55 2011 (r227437) +++ stable/8/lib/libthr/thread/thr_once.c Fri Nov 11 02:10:24 2011 (r227438) @@ -64,6 +64,8 @@ _pthread_once(pthread_once_t *once_contr struct pthread *curthread; int state; + _thr_check_init(); + for (;;) { state = once_control->state; if (state == ONCE_DONE)