From owner-freebsd-threads@FreeBSD.ORG Thu Oct 6 21:00:19 2011 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 5DB5C1065672 for ; Thu, 6 Oct 2011 21:00:19 +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 1C0E68FC12 for ; Thu, 6 Oct 2011 21:00:19 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p96L0Is7027088 for ; Thu, 6 Oct 2011 21:00:18 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p96L0IU8027084; Thu, 6 Oct 2011 21:00:18 GMT (envelope-from gnats) Resent-Date: Thu, 6 Oct 2011 21:00:18 GMT Resent-Message-Id: <201110062100.p96L0IU8027084@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-threads@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Alex Dupre Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 93EEA106566B for ; Thu, 6 Oct 2011 20:52:22 +0000 (UTC) (envelope-from ale@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 8418E8FC08 for ; Thu, 6 Oct 2011 20:52:22 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p96KqMNw004108 for ; Thu, 6 Oct 2011 20:52:22 GMT (envelope-from ale@freefall.freebsd.org) Received: (from ale@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p96KqMZJ004100; Thu, 6 Oct 2011 20:52:22 GMT (envelope-from ale) Message-Id: <201110062052.p96KqMZJ004100@freefall.freebsd.org> Date: Thu, 6 Oct 2011 20:52:22 GMT From: Alex Dupre To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: threads/161344: Failure to init TLS variables with func ptr inside shared lib X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Alex Dupre List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Oct 2011 21:00:19 -0000 >Number: 161344 >Category: threads >Synopsis: Failure to init TLS variables with func ptr inside shared lib >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-threads >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Oct 06 21:00:18 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Alex Dupre >Release: FreeBSD 8.2-STABLE i386 >Organization: >Environment: System: FreeBSD freefall.freebsd.org 8.2-STABLE FreeBSD 8.2-STABLE #4 r220774: Mon Apr 18 13:56:14 UTC 2011 simon@freefall.freebsd.org:/usr/obj/usr/src/sys/FREEFALL i386 >Description: Initialisation of Thread Local Storage variables to some values which are function address doesn't work inside a shared library. >How-To-Repeat: t1.c: int f(int x) { return x; } struct s_t { int (*func)(int); }; struct s_t __thread x = { f }; Build it as: cc -shared -o t1.so -fPIC t1.c t2.c: struct s_t { int (*func)(int); }; extern struct s_t __thread x; int main(int argc, const char *argv[]) { return (*x.func)(argc); } Build it as: cc t2.c t1.so export LD_LIBRARY_PATH=. ./a.out Segmentation fault >Fix: >Release-Note: >Audit-Trail: >Unformatted: