public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug nptl/5517] New: pthread: TLS array overlapped with guard pages in IA64
@ 2007-12-21  5:14 wangf at cn dot fujitsu dot com
  2007-12-21  5:19 ` [Bug nptl/5517] " wangf at cn dot fujitsu dot com
  2008-04-10 11:52 ` jakub at redhat dot com
  0 siblings, 2 replies; 3+ messages in thread
From: wangf at cn dot fujitsu dot com @ 2007-12-21  5:14 UTC (permalink / raw)
  To: glibc-bugs

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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug nptl/5517] pthread: TLS array overlapped with guard pages in IA64
  2007-12-21  5:14 [Bug nptl/5517] New: pthread: TLS array overlapped with guard pages in IA64 wangf at cn dot fujitsu dot com
@ 2007-12-21  5:19 ` wangf at cn dot fujitsu dot com
  2008-04-10 11:52 ` jakub at redhat dot com
  1 sibling, 0 replies; 3+ messages in thread
From: wangf at cn dot fujitsu dot com @ 2007-12-21  5:19 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From wangf at cn dot fujitsu dot com  2007-12-21 05:19 -------
Created an attachment (id=2152)
 --> (http://sourceware.org/bugzilla/attachment.cgi?id=2152&action=view)
this is the patch to solve this bug

this is the patch that expand stacksize for IA64 to solve this bug

-- 


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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug nptl/5517] pthread: TLS array overlapped with guard pages in IA64
  2007-12-21  5:14 [Bug nptl/5517] New: pthread: TLS array overlapped with guard pages in IA64 wangf at cn dot fujitsu dot com
  2007-12-21  5:19 ` [Bug nptl/5517] " wangf at cn dot fujitsu dot com
@ 2008-04-10 11:52 ` jakub at redhat dot com
  1 sibling, 0 replies; 3+ messages in thread
From: jakub at redhat dot com @ 2008-04-10 11:52 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From jakub at redhat dot com  2008-04-10 11:51 -------
This is just misunderstanding of what stacksize means on IA-64.  That's size of
the register stack and normal stack and guard page(s).  If there are any guard
pages, normal stack is limited to half of stacksize - guardsize, if there is no
guard, just the actually used normal stack plus actually used register stack
should be smaller than stacksize.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-04-10 11:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-21  5:14 [Bug nptl/5517] New: pthread: TLS array overlapped with guard pages in IA64 wangf at cn dot fujitsu dot com
2007-12-21  5:19 ` [Bug nptl/5517] " wangf at cn dot fujitsu dot com
2008-04-10 11:52 ` jakub at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).