From owner-freebsd-current@FreeBSD.ORG Wed Apr 20 02:49:01 2011 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9B31C106564A; Wed, 20 Apr 2011 02:49:01 +0000 (UTC) (envelope-from rysto32@gmail.com) Received: from mail-ey0-f182.google.com (mail-ey0-f182.google.com [209.85.215.182]) by mx1.freebsd.org (Postfix) with ESMTP id D67878FC15; Wed, 20 Apr 2011 02:49:00 +0000 (UTC) Received: by eyg7 with SMTP id 7so102364eyg.13 for ; Tue, 19 Apr 2011 19:48:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=eVpcdaRKOWKnSQOZ6YJH2pEfdy969hhoNo/aodrRTRc=; b=Xd2YYrDFXZuJsqFUnjSGcqnXFIBs2WExwgARNKy2JDcc8nacl3dBS1WC+4SXiwquXB AWkZAq2+w6ZY9GGbdOx9cOsDFPl87gtiObx78MfnKKfQ4lWzc6GsUVwYGnykFAckGgjV 0h6NWee5I7Q0sr00jIt0FjpBOhYyx3pGm6DWY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=YawG2hdBEsspsR6wtaDubk7P+EokAFiwxgl0clsBAWJ9LOk21px2cURQCUgMVeVXFk wrOK0AC2s44S1bZLEFwvngapkvOjR9/KcK/EwB6ow3DQp4Wdxw7fWlscWm/+yMr6SYdt OKiLtQufza3pbIwuMNMwuM7BKhQlu1obFSvmk= MIME-Version: 1.0 Received: by 10.213.96.228 with SMTP id i36mr72169ebn.100.1303267739627; Tue, 19 Apr 2011 19:48:59 -0700 (PDT) Received: by 10.213.32.4 with HTTP; Tue, 19 Apr 2011 19:48:59 -0700 (PDT) In-Reply-To: <4DAE4164.9080006@freebsd.org> References: <4DAE4164.9080006@freebsd.org> Date: Tue, 19 Apr 2011 22:48:59 -0400 Message-ID: From: Ryan Stone To: David Xu Content-Type: text/plain; charset=ISO-8859-1 Cc: FreeBSD Current , Ed Maste Subject: Re: [PATCH] Call _thr_check_init() from _pthread_once X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Apr 2011 02:49:01 -0000 On Tue, Apr 19, 2011 at 10:13 PM, David Xu wrote: > Have you tested that current code causes segfault ? > anyway, I can not reproduce it on my machne. > > Regards, > David Xu Yes, I had an application where libstdc++ was calling pthread_once while constructing a static object. As near as I can tell it's pure luck as to whether you'll hit this crash or not. If the linker happens to place a static initializer that calls pthread_once first in the list of static initializers, you crash. If instead something far more likely like pthread_mutex_lock is called first, you're fine. The backtrace for my executable was something like: #0 0x684dadd4 in _pthread_once (once_control=0x6887fdcc, init_routine=0x6883d740 <__gthread_trigger()>) at /usr/src/lib/libthr/thread/thr_once.c:84 #1 0x6883d992 in __gthread_active_p () at /tmp/buildutils.x86/x86-i686-pc-freebsd8/i686-pc-freebsd8/libstdc++-v3/include/i686-pc-freebsd8/bits/gthr-default.h:221 #2 __eh_globals_init () at gcc/libstdc++-v3/libsupc++/eh_globals.cc:98 #3 __static_initialization_and_destruction_0 () at gcc/libstdc++-v3/libsupc++/eh_globals.cc:110 #4 global constructors keyed to eh_globals.cc(void) () at gcc/libstdc++-v3/libsupc++/eh_globals.cc:146 #5 0x68848d06 in __do_global_ctors_aux () from /usr/local/mumble/lib/libstdc++.so.6