This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug nptl/5517] New: pthread: TLS array overlapped with guard pages in IA64


Hi,

Here are test procedures in IA64:

----------------------------------
[root@Fedora-ia64 TLS]# cat test.c
#include <stdio.h>
#include <pthread.h>

#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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]