Date: Thu, 6 Oct 2011 20:52:22 GMT From: Alex Dupre <ale@FreeBSD.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: threads/161344: Failure to init TLS variables with func ptr inside shared lib Message-ID: <201110062052.p96KqMZJ004100@freefall.freebsd.org> Resent-Message-ID: <201110062100.p96L0IU8027084@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201110062052.p96KqMZJ004100>