Thread-local storage issue

[ Available lists | Index of freebsd-hackers | Month of Sep 2011 | Week of 15 Sep 2011 | Raw email | View thread | Wrap long lines | Reply | Tag ]
From
Thinker K.F. Li <thinker@codemud.net>
Date
15 Sep 2011 03:13:22
Subject
Thread-local storage issue
Message-ID
20110915.105047.104045404.thinker@eeebox.branda.to

Referenced by

[ Hide this part ]
Hi Guys,

I was in trouble for an issue of TLS implementation of FreeBSD. It is
an issue of ld-elf.so actually. If I have a thread-local variable in
program, the value of the variable is not consistent after an
dlopen(). For example,

__thread int var = 50;

void modify() {
var = 100;
}

void show() {
printf("%d\n", var);
}

int main(int argc, char * const *argv) {
dlopen(...);
modify();
show();
}

If it is compiled with -fpic, it would print "50" while "100" is
expected. (-fpic is required for shared objects)

I have send-pr a patch as

http://www.freebsd.org/cgi/query-pr.cgi?pr=160721

I need someone to review it.
Thanks!

Elapsed time: 0.118 seconds