From owner-freebsd-hackers@FreeBSD.ORG Thu Sep 15 03:13:22 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 57B741065670 for ; Thu, 15 Sep 2011 03:13:22 +0000 (UTC) (envelope-from thinker.li@gmail.com) Received: from mail-yw0-f54.google.com (mail-yw0-f54.google.com [209.85.213.54]) by mx1.freebsd.org (Postfix) with ESMTP id 1347D8FC08 for ; Thu, 15 Sep 2011 03:13:21 +0000 (UTC) Received: by ywp17 with SMTP id 17so2330549ywp.13 for ; Wed, 14 Sep 2011 20:13:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:date:message-id:to:subject:from:x-mailer:mime-version :content-type:content-transfer-encoding; bh=xj6ThdeeuTBgwoFCGPtAKiszx0M0pJpSrKcTiXTWd1U=; b=x+x3YK0FCvIsIlBPjIIEQhieleTDbk2+UMhocvDnfGqyBgMJnAvqDnA/OYIm8XSmhG JzuDn0m+yxVZ6rPj8SkMuYvVLyViPhM3fHTdOPsi0BQTG92VTiwmbxr1Ie1vBHXXxMVm m4h/RxyzFrhw4tzajGwiKtKUZqbGIsWOILWGI= Received: by 10.236.77.104 with SMTP id c68mr3135129yhe.69.1316054820463; Wed, 14 Sep 2011 19:47:00 -0700 (PDT) Received: from eeebox.branda.to (123-194-52-90.dynamic.kbronet.com.tw. [123.194.52.90]) by mx.google.com with ESMTPS id o21sm2403117yhi.8.2011.09.14.19.46.57 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Sep 2011 19:46:59 -0700 (PDT) Sender: Thinker Li Received: from localhost (localhost [127.0.0.1]) by eeebox.branda.to (8.14.4/8.14.4) with ESMTP id p8F2olgB037409 for ; Thu, 15 Sep 2011 10:50:47 +0800 (CST) (envelope-from thinker@branda.to) Date: Thu, 15 Sep 2011 10:50:47 +0800 (CST) Message-Id: <20110915.105047.104045404.thinker@eeebox.branda.to> To: freebsd-hackers@freebsd.org From: "Thinker K.F. Li" X-Mailer: Mew version 6.2 on Emacs 23.2 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Thu, 15 Sep 2011 03:51:04 +0000 Subject: Thread-local storage issue X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Sep 2011 03:13:22 -0000 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!