From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4913 invoked by alias); 21 Dec 2007 05:14:06 -0000 Received: (qmail 4868 invoked by uid 48); 21 Dec 2007 05:13:53 -0000 Date: Fri, 21 Dec 2007 05:14:00 -0000 From: "wangf at cn dot fujitsu dot com" To: glibc-bugs@sources.redhat.com Message-ID: <20071221051352.5517.wangf@cn.fujitsu.com> Reply-To: sourceware-bugzilla@sourceware.org Subject: [Bug nptl/5517] New: pthread: TLS array overlapped with guard pages in IA64 X-Bugzilla-Reason: CC Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org X-SW-Source: 2007-12/txt/msg00134.txt.bz2 Hi, Here are test procedures in IA64: ---------------------------------- [root@Fedora-ia64 TLS]# cat test.c #include #include #define TLS_NUM 67400 __thread unsigned long test[TLS_NUM]; void *routine(void *arg) { int i; #ifdef REVERSE for (i = TLS_NUM-1; i >= 0; i--) { #else for (i = 0; i < TLS_NUM; i++) { #endif test[i] = i; printf("i = %d\n", test[i]); } return NULL; } int main(int argc, char **argv) { pthread_t pid; pthread_attr_t attr; size_t stacksize; pthread_attr_init(&attr); pthread_attr_getstacksize(&attr, &stacksize); printf("stacksize: %lu\n", (unsigned long)stacksize); pthread_create(&pid, &attr, routine, NULL); pthread_join(pid, NULL); return 0; } [root@Fedora-ia64 TLS]# ulimit -s 1024 [root@Fedora-ia64 TLS]# gcc -o test test.c -lpthread [root@Fedora-ia64 TLS]# ./test stacksize: 1048576 i = 0 i = 1 ... i = 36 i = 37 Segmentation fault [root@Fedora-ia64 TLS]# gcc -o test test.c -lpthread -DREVERSE stacksize: 1048576 i = 67399 i = 67398 ... i = 2087 i = 2086 Segmentation fault -------------------------- Seeing from above, the middle of the tls arrary can't be accessed. This is because the array overflows the normal stack and extends to the register stack. As show below: |<--------ARRAY-------->| |-------------------------------------------------| |<---register stack--->| guard |<--normal stack-->| So the middle of ARRAY is in the guard area, When accessing this area, the program receives a SIGSEGV. ARRAY can fit into the stack, but half of the stack is assigned to register stack, so the normal stack can't place the whole ARRAY. So I think the stack should be expanded for IA64. -- Summary: pthread: TLS array overlapped with guard pages in IA64 Product: glibc Version: unspecified Status: NEW Severity: normal Priority: P2 Component: nptl AssignedTo: drepper at redhat dot com ReportedBy: wangf at cn dot fujitsu dot com CC: glibc-bugs at sources dot redhat dot com http://sourceware.org/bugzilla/show_bug.cgi?id=5517 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.