Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sat, 6 Oct 2012 16:58:05 -0400
From: Rich Felker <dalias@...ifal.cx>
To: musl@...ts.openwall.com
Subject: Re: TLS (thread-local storage) support

On Sat, Oct 06, 2012 at 10:39:39PM +0200, Szabolcs Nagy wrote:
> * Szabolcs Nagy <nsz@...t70.net> [2012-10-06 16:33:01 +0200]:
> > should the attached code work with dlopen
> > when compiled as a dso?
> > 
> > (i wanted to check if the alignments are ok after a dlopen,
> > but i can see how this usage may not be supported)
> > 
> > it seems it dies here in the ctor
> 
> a more minimal example:
> 
> a.c:
> __thread int xx;
> int *p;
> __attribute__((constructor)) static void init(void)
> {
>         p = &xx;
> }
> 
> b.c:
> #include <dlfcn.h>
> void *h;
> int main()
> {
>         h = dlopen("./a.so", RTLD_LAZY);
> }
> 
> compiled as
> musl-gcc -shared -fPIC -g -o a.so a.c
> musl-gcc -g -o b b.c
> 
> ../b segfaults in init at p=&xx

Very stupid issue, fixed by commit
92e1cd9b0ba9a8fa86e0346b121e159fb88f99bc:

http://git.musl-libc.org/cgit/musl/commit/?id=92e1cd9b0ba9a8fa86e0346b121e159fb88f99bc

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.